Solved

datagrid view properties

Posted on 2009-04-11
7
229 Views
Last Modified: 2013-12-20
hello i  use datagrid in a form and i want 1) to move the fields in the above photo in the center 2) put a color behind the fields 3) minus the font of the fields.How i  can do these

i am using vb 2005

Thnks for the help
untitled.PNG
0
Comment
Question by:demoniumz
  • 3
  • 2
  • 2
7 Comments
 
LVL 1

Author Comment

by:demoniumz
ID: 24124772
anyone to help pls
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24124914
HELLO
0
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 24125032
1) To center the header text

Me.DataGridView1.RowHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
2) On the column 3 (index 2) but some backcolor

Me.DataGridView1.Columns(2).DefaultCellStyle.BackColor = Color.AliceBlue
3) You want to change the font ?

Me.DataGridView1.Font = New Font("Arial", 8)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:demoniumz
ID: 24125190
center not work  can  i move  the space between  each field  to be more nice  

example ok (these i need to appear)
Categor Name !Category ident

not  like these (appear now)
Categories Name !    Category ident    !      picture !
 
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24125822
Can you show a picture ?
Just note that it will not be correctly center because some space on the right are reserved to the sort arrows. If you don't need to sort you can remove it that option and the text will be correctly at the center.
0
 
LVL 33

Expert Comment

by:jppinto
ID: 24125955
What jpaulino is saying is that, for instance, use this to center the header text:

Me.DataGridView1.RowHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter

and on the columns that you don't need to sort ascending or descending, to remove the sort glyph (the small triangle that appears on the header, right of the header text), use this for each column:

Me.DataGridView1.Columns("CategoryName").SortMode = DataGridViewColumnSortMode.NotSortable

this will remove the sort glyph and allow the text to be sorted right on the middle of the column header.

jppinto

0
 
LVL 33

Expert Comment

by:jppinto
ID: 24125989
Check the picture of this post to see if this is what you're getting on the headers texts:

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_24303598.html

with my previous post, you will be able to solve the problem as I solved mine.

jppinto
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

863 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

23 Experts available now in Live!

Get 1:1 Help Now