Solved

How To Align Text In Center In Datagridview

Posted on 2008-06-19
7
8,372 Views
Last Modified: 2008-07-06
How To Align Text In Center In Datagridview Cells and HeaderText  
0
Comment
Question by:Ahmadal_najjar2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
7 Comments
 
LVL 33

Expert Comment

by:jppinto
ID: 21821798
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
 

Author Comment

by:Ahmadal_najjar2003
ID: 21822208
Thats work for the cell alignment , but what about the Header Text .
0
 

Accepted Solution

by:
Ahmadal_najjar2003 earned 0 total points
ID: 21823008
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
 
LVL 3

Expert Comment

by:RHansonLinea
ID: 21879955
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
bit defender blocks good applications 2 107
Access 2013 combo box not working 3 60
Visual Studio search word table and return Cell index 8 78
Hide vba in gp 7 118
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question