By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,029 Members | 1,304 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,029 IT Pros & Developers. It's quick & easy.

Datagridview alignment does not work

P: 2
Hi, I'm trying to align datagridview columns at once to middlecenter. It works for the first column and does not for the others. I suspect it's a matter of the datasource property which is bind to a datatable which catches data from a
SQL Server table. Below is my simple code and I thought that after this code runs I would have every column aligned to middlecenter:

With Datagridview

.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells

With .ColumnHeadersDefaultCellStyle
.Alignment = DataGridViewContentAlignment.MiddleCenter
End With

With .RowsDefaultCellStyle
.Alignment = DataGridViewContentAlignment.MiddleCenter
End With

.ScrollBars = ScrollBars.Horizontal

End With

Apr 22 '10 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 210
set the horizontalalign property of gridview rowstyle to center. That should do it.
Apr 23 '10 #2

P: 2
I am working with the new DataGridView and your answer applies to the former GridView. If you have any idea about how to solve this with the DataGridView new control I'd appreciate a lot. Thank you.
Apr 23 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.