Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How To Align Text In Center In Datagridview

Posted on 2008-06-19
7
Medium Priority
?
9,205 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

610 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