Solved

Help with changing datagridview's background and  forecolors

Posted on 2014-02-24
4
184 Views
Last Modified: 2014-02-24
Hi,

How do you change the background or Forecolor of a column in a DataGridView using VB.NET?

Thanks,

Victor
0
Comment
Question by:vcharles
  • 2
  • 2
4 Comments
 
LVL 40
ID: 39883705
DataGridView1.Columns(1).DefaultCellStyle.BackColor = Color.Red
DataGridView1.Columns(1).DefaultCellStyle.ForeColor = Color.Blue

You can use the name of the column instead of its index if you prefer so:

DataGridView1.Columns("Name").DefaultCellStyle.BackColor = Color.Red
DataGridView1.Columns("Name").DefaultCellStyle.ForeColor = Color.Blue
0
 

Author Comment

by:vcharles
ID: 39883768
Hi,

Sorry for not being clear, I meant the column's header.

Thanks,

Victor
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 39883839
DataGridView1.Columns(1).HeaderCell.Style.BackColor = Color.Red
0
 

Author Closing Comment

by:vcharles
ID: 39883901
Thank You.
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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

948 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

22 Experts available now in Live!

Get 1:1 Help Now