Wrap Winforms DataGrid header

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm looking for a way to wrap a text in Winforms DataGrid header (see below).
I know it can be done to the cells in the grid by overriding the paint method
but i can't seem to find a similar way to handle the column headers. Any help
would be much appreciated.

ex: _______________________
|Column1 |Really Long Column 2|

desired format
|Column1 |Really Long|
| |Column 2 |

Regards

Dave
 
First set the HeaderText for the columns in code, eg

dataGridBoolColumn2.HeaderText = "Really Long\nColumn 2";

Next, set the dataGrid1.HeaderFont to a larger font. This increases the
height of the Headers, but the Headers are still displayed using the
dataGrid1.TableStyles[ 0 ].HeaderFont font.

Regards,
Phil.
 
Back
Top