Select Categories Below
Quomon shares its advertising revenue with contributing experts that answer questions effectively. Join our community to share your knowledge and earn an income as you go.
Status: Closed Points: 75 Time: 14:28 - Apr 04, 2007
dustPuppy
I need to align some of the columns in a datagridview to the right. But I can't find any property to control the alignment. How can i accomplish that? I'm programming in c#.net (visual studio 2005).
Categories:
Add Categories
When adding more than one category, separate them with commas.
Advertisement
PeterNZ
Date:: Apr 04, 2007
Time:: 15:59
Either select your DataGridView in thedesigner window and set the property "RowStyle|HorizontalAlign" to "Right" or change the HTML code and add "align=right" to the <td> tags. Cheers Peter
Time:: 16:25
thanks, Peter. I forgot to say that it's windows forms, not asp.net, so the solution doesn't work unfortunately.
Time:: 16:36
Oh sorry, I am deep in ASP.Net development at the moment so my brain was focussed on this! Sorry! For a windows app, look at RowTemplate property of the GridView component, expand the sub nodes and click on the [...] for DefaultCellStyle. This will open the CellStyle Builder. Set the Alignment property in the Layout section. Cheers Peter
Date:: Apr 05, 2007
Time:: 05:00
thank you Peter, that worked. I found that the equivalent by code is: this.dataGridView1.Columns["CustomerName"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; and the points go to..... Peter!!! :)
Question Answered
This question has been closed, and points have been rewarded to the following experts:
You're welcome however to comment or give additional information or if you wish, you have the ability to write a Tutorial in the Tutorial Area.
Answer this Question
New User
Email:
Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address
Registered User
Username:
Password:
Forgot Your Password?
Enter your email address below and we will resend your login information to you.
Login Information Sent
Questions
how can I make a datagridview sortable in .net?
You have 100 characters to use
Rank
Expert
Points
1.
885
2.
560
3.
488
4.
200
5.
75
6.
50
7.
8.
30
9.
25
10.
20
Register today to share your knowledge with the community and be recognized and rewarded for your contributions.
Register Here
"Psst, Quomon is a great site. Pass it on." Tell a Friend | Link To Us | Save to Delicious | Digg it
Language Options
English:
Español:
Sponsors
Questions and Answers Software Real Estate Postcards Marketing Fulfillment