A DataGridView
column header may be set with code below, this quite set multiline header labels just fit and nice.
ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize
But a single line column header shapes quite ugly, namely a narrow row. Trying below code together to increase height even does not work:
Columns[0].HeaderCell.Style.Padding = new Padding(0, 5, 0, 5)
Is there way both use AutoSize
and get nice height of column header in case of single line labels?
CodePudding user response:
try this
dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
CodePudding user response:
if you set ColumnHeadersHeightSizeMode
to AutoSize
then it is not allowed to change Column Heigt
on run time in accordance with Header Labels Length
.
You must add this code on initialize:
this.dataGridView1.ColumnHeadersDefaultCellStyle.Padding = new System.Windows.Forms.Padding(0, 5, 0, 5);
Change '5' as you wish to what padding volume you would like see...