I am just wanting to change the colour of a row if it has a zero in it but I keep getting this error:
foreach (DataGridViewRow row in dataGridView1.Rows)
{
string comp = "0";
if (row.Cells[4].Value.ToString() == comp)
{
row.DefaultCellStyle.ForeColor = Color.Red;
}
if (row.Cells[4].Value.ToString() == "1")
{
row.DefaultCellStyle.ForeColor = Color.Green;
}
}
Also, I cannot get my code to display in this (stackoverflow) window without assistance. How can I do this?