Solved

Help with changing datagridview's background and  forecolors

Posted on 2014-02-24
4
185 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
.net and XML report from SCCM 5 25
Javascript to set controls visibility 5 38
ASP.NET MVC 2 31
vb.net class 3 17
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

803 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