• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

Help with changing datagridview's background and forecolors

Hi,

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

Thanks,

Victor
0
vcharles
Asked:
vcharles
  • 2
  • 2
1 Solution
 
Jacques Bourgeois (James Burger)PresidentCommented:
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
 
vcharlesAuthor Commented:
Hi,

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

Thanks,

Victor
0
 
Jacques Bourgeois (James Burger)PresidentCommented:
DataGridView1.Columns(1).HeaderCell.Style.BackColor = Color.Red
0
 
vcharlesAuthor Commented:
Thank You.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now