Solved

How To Align Text In Center In Datagridview

Posted on 2008-06-19
7
7,595 Views
Last Modified: 2008-07-06
How To Align Text In Center In Datagridview Cells and HeaderText  
0
Comment
Question by:Ahmadal_najjar2003
  • 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now