jppinto
asked on
DataGridView Header text not centered
I've a DataGridView where the header texts aren't correctly centered, as you can see by the picture. I've the following code for my DataGridView. Why does this happens?
Thanks for your help.
jppinto
Thanks for your help.
jppinto
Me.grdMissingParts.RowHeadersWidth = 25
Me.grdMissingParts.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
Me.grdMissingParts.Columns("Part Number").Width = 150
Me.grdMissingParts.Columns("Part Number").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
Me.grdMissingParts.Columns("Descrição").Width = 250
Me.grdMissingParts.Columns("Descrição").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
Me.grdMissingParts.Columns("URQ").Width = 60
Me.grdMissingParts.Columns("URQ").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
Me.grdMissingParts.Columns("Paragem").Width = 60
Me.grdMissingParts.Columns("Paragem").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
DataGridView.JPG
ASKER
No, I don't have spaces in the column name. The problem is with the first 3 columns name as you can see by the picture, they are not well centered.
Strange ... Try this snippet after your code
For Each col As DataGridViewColumn In Me.DataGridView1.Columns
col.HeaderText = col.HeaderText.ToString.Trim
Next
ASKER
I've tryed your code but with no sucess...the problem still exists!
jppinto
jppinto
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you mean the column "URQ" ? Don't you have spaces in the column name ?