Reputation: 883
I have a filled grid view from a dataset; i want to check Column[4] cells (except header) that if it's cell's value less that 0 , it's background change to red .
please help ... Thanks alot
Upvotes: 1
Views: 4928
Reputation: 720
Here is an example that works in windows forms.
dataGridView1.Rows.Add(3, 2, -3);
dataGridView1.Rows.Add(1, -2, 3);
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (!row.IsNewRow && int.Parse(row.Cells[2].Value.ToString()) < 0)
row.Cells[2].Style.BackColor = Color.Red;
}
Upvotes: 3