How to set coloumn background color in DataGridView

I would like to know which property should be used to set the background color of a column of a DataGridView table at design time. I do not want to do this programmatically.

+3
source share
2 answers

You need to set the property EnableHeadersVisualStylesto falseto configure your user settings.

this.myDgv.EnableHeadersVisualStyles = false;
this.myDgv.Columns[ 0 ].HeaderCell.Style.BackColor = Color.Red;

That should work.

// EDIT: Ah, you don’t want to do this with code, but the general approach works with the designer too. The property EnableHeadersVisualStylesis a direct property of the DataGridView and the color of the column set in the property ColumnHeadersDefaultCellStyle.

+3
source

DataGridView → ... , DefaultCellStyle. ... , .

+3

Source: https://habr.com/ru/post/1781622/


All Articles