Click here to Skip to main content
16,021,041 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I used the code below to color the HeaderCell of the first column. I wonder why it did not work. I also set the ColumnHeadrDefaultStyle property at design time but amazingly it did not work neither. What should I do to get done such a simple task?

dataGridView1.Columns[0].HeaderCell.Style.ForeColor = Color.Red; 


Thank you very much
Posted

1 solution

Try any one of this for change the back color of header row

GridView1.HeaderRow.Cells[0].BackColor = Color.Red;
GridView1.Columns[0].HeaderStyle.BackColor = Color.Red;


Try this for change the text color of header row

GridView1.HeaderRow.Cells[0].ForeColor = Color.Red;
GridView1.Columns[0].HeaderStyle.ForeColor = Color.Red;
 
Share this answer
 
Comments
ahhashemi 27-Jul-10 3:15am    
Thank you very much Dear Deepu,

But as I implicitly stated, I’m using "dataGridView" control not "GridView" one and "dataGridView" does not have property called "HeaderRow". Furthermore, is there any "GridView" control? I can not find it. The next line in the proposed code is the same as that of written in the question and as said before, it did not work. So unfortunately the question still left unsolved.
Toli Cuturicu 27-Jul-10 8:33am    
Reason for my vote of 2
Read the question before answering, please.
Toli Cuturicu 27-Jul-10 8:34am    
"Furthermore, is there any "GridView" control? I can not find it."
Try: gridView1 = new GridView(); :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900