[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 9436
  • Last Modified:

How To Align Text In Center In Datagridview

How To Align Text In Center In Datagridview Cells and HeaderText  
0
Ahmadal_najjar2003
Asked:
Ahmadal_najjar2003
  • 2
1 Solution
 
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
 
Ahmadal_najjar2003Author 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
 
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now