Solved

Help with changing datagridview's background and  forecolors

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 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

16 Experts available now in Live!

Get 1:1 Help Now