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
.AutoSizeColumn sMode = DataGridViewAut oSizeColumnsMod e.DisplayedCell s
With .ColumnHeadersD efaultCellStyle
.Alignment = DataGridViewCon tentAlignment.M iddleCenter
End With
With .RowsDefaultCel lStyle
.Alignment = DataGridViewCon tentAlignment.M iddleCenter
End With
.ScrollBars = ScrollBars.Hori zontal
End With
Tks,
Rubens
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
.AutoSizeColumn sMode = DataGridViewAut oSizeColumnsMod e.DisplayedCell s
With .ColumnHeadersD efaultCellStyle
.Alignment = DataGridViewCon tentAlignment.M iddleCenter
End With
With .RowsDefaultCel lStyle
.Alignment = DataGridViewCon tentAlignment.M iddleCenter
End With
.ScrollBars = ScrollBars.Hori zontal
End With
Tks,
Rubens
Comment