Question?
"I've found a lot of answers on how to align the Header Text for a column but when I set the HeaderText to MiddleRight alignment, there is some sort of padding after the Header text that I can't figure out how to get rid of
The code I use to Right Align the column is below:
DataGridView1.Columns(1).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight 'Aligns the Header Text
DataGridView1.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight 'Just aligns the cell contents
I should also mention that I've tried turning EnableHeadersVisualStyles off and that did not solve the problem. I've also tried TopRight and BottomRight with no change."
AnswerThere's a space for the up/down arrow for sorting on that column. If you set the "SortMode" to "NotSortable", you will get what you want:
DataGridView1.Columns(1).S
DataGridView1.Columns(1).H
DataGridView1.Columns(1).D
0 comments