[SOLVED] DataGridView Column Header Rotation

Answered
0
0

Hi,

I haven’t been able to spot how to achieve the following (see attached), can you advise the best approach?

Cheers,
Neil

Attachment
  • You must to post comments
Best Answer
0
0

Hi Neil,

one approach could be to use the html of the column title directly:

col_vertical

Column HeaderText = <div style=”transform:rotateZ(-90deg)”>Column0</div>

Please make sure to set AllowHtml = True.
It´s probably better to make those columns not resizable or let them shrink below a certain size.
In that case the Visibility menu won´t be available for that column too.

If you can live with these restrictions, it´s a quite easy way to achieve vertical columns.

Hope that helps.

Best regards
Frank

Attachment
  • You must to post comments
0
0

That did it!  Many thanks.

  • You must to post comments
0
0

Hi Neil,

you might want to experiment with

HeaderStyle.Alignment

and/or adding

translateX(-??px)

to the HTML.

Hope that helps.

Best regards
Frank

  • You must to post comments
0
0

Many thanks Frank, that works well!

Using:
dataGridView1.ColumnHeadersHeight = 300;
dataGridView1.Columns.Add(new DataGridViewColumn { AllowHtml = true, Width = 30, HeaderText = $”<div style=’transform:rotateZ(-90deg)’>{action.Description}</div>” });

Produces the attached.  I’m just a little stuck as to why the text is offset so high and therefore clipping?

Cheers,

Neil

Attachment
  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.