Link to home
Start Free TrialLog in
Avatar of TeflonJon
TeflonJon

asked on

DataGridView Column Header Alignment

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.  Since this is hard to describe, I've posted a sample picture with the problem circled in red at: http://i7.photobucket.com/albums/y279/abso_lushen/EESample.jpg

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.

Thanks in Advance,
Jon Beck
ASKER CERTIFIED SOLUTION
Avatar of vadim63
vadim63
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TeflonJon
TeflonJon

ASKER

Thanks for the answer.  I think the best solution for me is to use the ComponentOne FlexGrid (or similar) since I still need to allow my user to sort by column header.  With the reserved space, narrow columns still look like the column header is left aligned and I know my clients will complain about that.  I think Microsoft came out with a much better DataGridView this time but it's still not quite got the features we need for a few of our apps...  Oh well.  Thanks again.

Jon