I have a simple database that displays information in various datagridview controls on the same form. One thing I would like to do is change the colour of a row if the value from a cell returns "poor", or "fair"
I call a private function to go through each row in the datagrid just after it is connected to the bingingSource. I can get it to change the colour, but it formats all the rows with that colour, and I want only the row that returned the value to be changed.
private void checkForSurveyColour()
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
try
{
CNumColour = dataGridView1.CurrentRow.Cells["RepVisits"].FormattedValue.ToString();
if (CNumColour != null)
{
foreach(DataGridViewCell cells in row.Cells)
{
if (CNumColour == "Fair")
{
cells.Style.ForeColor = Color.Pink;
}
else if (CNumColour == "Poor")
{
cells.Style.ForeColor = Color.Red;
}
}
}
}
catch(System.Exception ex)
{
}
}
}
Thanks.