I have tried to do it without success.
Is it possible ?
This question is related to
c#
.net
winforms
datagridview
It can be done.
From the designer: Select your DataGridView Open the Properties Navigate to ColumnHeaderDefaultCellStype Hit the button to edit the style.
You can also do it programmatically:
dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.Purple;
Hope that helps!
dataGridView1.EnableHeadersVisualStyles = false;
dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.Blue;
If you want to change a color to single column try this:
dataGridView1.EnableHeadersVisualStyles = false;
dataGridView1.Columns[0].HeaderCell.Style.BackColor = Color.Magenta;
dataGridView1.Columns[1].HeaderCell.Style.BackColor = Color.Yellow;
dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.Blue;
Source: Stackoverflow.com