Is it possible to set color on a specific column in a DataGridView

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!

This DataGridView is connected to the DataTable.
I just wonder if it's possible to set a color on a specific column.
I have a column that is autoincrement and I want this DataColumn to have a
specific color.

//Tony
 
Hi Tony,

If you have the DataTable bound to the DataGridView at design time, you can
do this by invoking the "Edit Columns..." task on the control, selecting the
column and editing its DefaultCellStyle. The designer will let you choose a
BackColor for the column.

Alternative, you can do it in code by instantiating a new
DataGridViewCellStyle class, setting the desired BackColor property and
updating your DataGridViewColumn with the cell style.
 
Hi Tony,

If you have the DataTable bound to the DataGridView at design time, you can
do this by invoking the "Edit Columns..." task on the control, selecting the
column and editing its DefaultCellStyle. The designer will let you choose a
BackColor for the column.

Alternative, you can do it in code by instantiating a new
DataGridViewCellStyle class, setting the desired BackColor property and
updating your DataGridViewColumn with the cell style.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top