narasiman rao

narasiman rao

  • NA
  • 519
  • 747.2k

for particular row i have to give fore color in datagridview

Jan 9 2013 2:45 AM
for particular row i have to give fore color in datagridview using c sharp in windows application.


Design as follows in the data grid view;
 
Date  Session  VRV CK CNN CKK MS TMS RK MK
 
8/1/2012   1           coursenmae
8/1/2012    2
8/1/2012  3
8/1/2012    4
 

in the above i want to give the fore color for Date and Session in the data grid view how to do

i try the below thing but it is not working;

Code as follows;

private void CellColorChange()
{
for (int i=0; i <= Datagridview.Items.Count -1; i++)
{
Datagridview .Items[i].Cells[
0].ForeColor = System.Drawing.Color.FromName("#8BB381");
Datagridview .Items[i].Cells[
1].ForeColor = System.Drawing.Color.FromName("#8BB381");
}
}

when i type the above code the after datagridview.items that items is not coming after dot.



please check it and send the code.



Answers (2)