C# - DatagidView show full header text
I have a datagrid in my application. My datagridview columns have very long name开发者_运维知识库s and I would like that datagridview would show full text of the column header. I have tried change AutoSizeColumnMode
property to ColumnHeader
, but I do that then I wont be able to resize the columns, I wont be able to make the cell bigger or smaller.
Wich properties should I change so that my datagridview shows full text on the columns?
Help is very appreciated.
In the Winform designer leave the AutoSizeColumnMode
setting to ColumnHeader
, but in your form's constructor (after calling InitializeComponent()
) set all your DGV columns AutoSizeColumnMode
property to None
:
foreach (DataGridViewColumn col in dataGridView1.Columns) {
col.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
}
When your form loads your DGV Columns will be sized to the column header but your users will be able to resize column widths.
精彩评论