How To Align Text In Center In Datagridview

How To Align Text In Center In Datagridview Cells and HeaderText  
Ahmadal_najjar2003Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Ahmadal_najjar2003Connect With a Mentor Author Commented:
I Found x-solution like this
DataGridView1.Columns(1).SortMode = DataGridViewColumnSortMode.NotSortable
DataGridView1.Columns(1).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight 'Aligns the Header Text
DataGridView1.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight 'Just aligns the cell contents
0
 
jppintoCommented:
On design mode, on your form, select the datagridview, right click mouse and select Edit Columns. Select the column and on the DefaultCellStykle propertie click on the propertie and open another set of properties where you can the Layout-Alignment propertie.

jppinto
0
 
Ahmadal_najjar2003Author Commented:
Thats work for the cell alignment , but what about the Header Text .
0
 
RHansonLineaCommented:
Ahmadal: Thanks for posting your solution... That is just not intuitive and I always have to look it up... Anyway, you helped me out...
0
All Courses

From novice to tech pro — start learning today.