Data Grid properties- SOS
-
Can I change the color of perticular cell in C# for DataGrid control. I want to change the color of the cells which have numeric value below 100.
foreach (GridViewRow row in GridView1.Rows) { long cellValue = long.Parse(row.Cells[1].Text.ToString()); if (cellValue > 100) { row.Cells[1].BackColor = System.Drawing.Color.Red; row.Cells[1].ForeColor = System.Drawing.Color.Blue; } } Here Cells[1] 1 should be the index of the Column that you want to compare. for(int i=0;i<500;i++) Console.WriteLine("I Love C# \n");
-
foreach (GridViewRow row in GridView1.Rows) { long cellValue = long.Parse(row.Cells[1].Text.ToString()); if (cellValue > 100) { row.Cells[1].BackColor = System.Drawing.Color.Red; row.Cells[1].ForeColor = System.Drawing.Color.Blue; } } Here Cells[1] 1 should be the index of the Column that you want to compare. for(int i=0;i<500;i++) Console.WriteLine("I Love C# \n");