Solved

datagrid view properties

Posted on 2009-04-11
7
234 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
SharePoint Admin?

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

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

756 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