I have a datagridview that has two columns, what i want to do is iterate over the rows and colour only the second row based on a condition, so far i have this:
foreach (DataGridViewRow row in dsgDataGrid.Rows)
{
var stock = Convert.ToInt32(row.Cells[1].Value);
if (stock == 0)
{
row.DefaultCellStyle.BackColor = Color.Red;
}
if (stock >= 1 && stock <= 5)
{
row.DefaultCellStyle.BackColor = Color.LightSalmon;
}
}
That gets the entire row red (where the value is 0) but can anyone advise on how to only affect the cell in the second column based on the condition?
Thanks.