How to set coloumn background color in DataGridView
11,419
Solution 1
You have to set the property EnableHeadersVisualStyles
to false
in order to get your custom settings work.
this.myDgv.EnableHeadersVisualStyles = false;
this.myDgv.Columns[ 0 ].HeaderCell.Style.BackColor = Color.Red;
This should work.
// EDIT: Ahh you don't want to do it via code, but the generel approach works also with the designer. The property EnableHeadersVisualStyles
is a direct property of the DataGridView and the color of column you set in the property ColumnHeadersDefaultCellStyle
.
Solution 2
Right-click on DataGridView -> Edit Columns... then choose your column, click on DefaultCellStyle. This will give you ... button there, click it and set style as you want.
Author by
Justin
Updated on June 27, 2022Comments
-
Justin almost 2 years
I would like to know which property should I use to set background color of column of DataGridView table at design time. I don't want to do it programatically.