Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help with changing datagridview's background and  forecolors

Posted on 2014-02-24
4
Medium Priority
?
199 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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 article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

886 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