I'm using dataGridView in Windows Forms to show the database and want to color it. If [Solver] column is NULL it should paint LightSalmon, else LightGreen. However even if the column value is NULL it still see it as not null and paint into LightGreen.
This is my table:
[Id]
[Employee]
[Section]
[Machine]
[Station]
[MachNo]
[Area]
[Type]
[Desc]
[Recommendation]
[Date]
[Solver]
[Process]
public void Color()
{
for(int i = 0; i< dataGridView1.Rows.Count; i++)
if (DBNull.Value.Equals(dataGridView1.Rows[11]))
{
dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.LightSalmon;
}
else
{
dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.LightGreen;
}
}
dataGridView1.Refresh().