I am wanting to change the backcolor of a specific row/cell in a DataGridView control using the following code:
This delegate gets called but the backcolor doesn't change. Am I missing something?
tia,
flynn
Code:
private void CustomGridCellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (dgSearchResults.Columns[e.ColumnIndex].Name.Equals("column1"))
{
// Ensure that the value is a string.
String stringValue = e.Value as string;
if (stringValue == null) return;
switch (stringValue)
{
case "G":
e.CellStyle.BackColor = Color.Gold;
break;
case "S":
e.CellStyle.BackColor = Color.Silver;
break;
case "N":
break;
}
}
}
This delegate gets called but the backcolor doesn't change. Am I missing something?
tia,
flynn