I am trying to change the column header text to red and I have this code:
dCol.HeaderCell.Style.ForeColor = Color.Red;
This change does indeed stick and I can see it in the debugger. However,
the column name text is still showing up as black. I have seen this same
problem asked around but with no answer. Does anybody know what is going on?
Thanks.
Manish Bafna - 26 Jun 2007 06:34 GMT
Hi,
Try following code:
DataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.Navy
DataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
DataGridView1.ColumnHeadersDefaultCellStyle.Font = New
Font(songsDataGridView.Font, FontStyle.Bold)
--
Hope this answers your question.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.
> I am trying to change the column header text to red and I have this code:
>
[quoted text clipped - 5 lines]
>
> Thanks.
Manish Bafna - 26 Jun 2007 06:41 GMT
Hi,
In order to set forecolor/backcolor of particular column you can something
like this:
DataGridView1..Columns[4].DefaultCellStyle.BackColor = Color.Navy
DataGridView1..Columns[4].DefaultCellStyle.ForeColor = Color.White
dataGridView1.Columns[4].DefaultCellStyle.Font = new
Font(DataGridView.DefaultFont, FontStyle.Italic);

Signature
Hope this answers your question.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.
> I am trying to change the column header text to red and I have this code:
>
[quoted text clipped - 5 lines]
>
> Thanks.
Oldman - 26 Jun 2007 11:21 GMT
Wouldn't that change the colors of all the cells in that column?
I just want the header cell text color to change.
> Hi,
> In order to set forecolor/backcolor of particular column you can something
[quoted text clipped - 13 lines]
> >
> > Thanks.
Manish Bafna - 26 Jun 2007 13:19 GMT
Hi,
Try this code:
dataGridView.Rows(0).Cells(2).DefaultCellStyle.BackColor = Color.Navy
//for setting backcolor of second column

Signature
Hope this answers your question.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.
> Wouldn't that change the colors of all the cells in that column?
> I just want the header cell text color to change.
[quoted text clipped - 16 lines]
> > >
> > > Thanks.
Oldman - 26 Jun 2007 14:01 GMT
I found the problem. I needed to set EnableHeadersVisualStyles = false.
> Hi,
> Try this code:
[quoted text clipped - 21 lines]
> > > >
> > > > Thanks.