I have a datagridview which I am populating from a datasource using dgv.DataSource = table. I then use a cell formatting event to change the color of specific cells in the datagridview depending on a value. The problem that I am facing is that when looking at the data on certain pc's some random cells will appear white with no data in. The code I am using to set the color is below however it is not just the cells which I have set custom colors which appear white:
private void dgvRaw_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e != null)
{
DataGridView dgv = (DataGridView)sender;
if (dFlags.ContainsKey(dgv.Columns[e.ColumnIndex].Name))
{
e.CellStyle.ForeColor = Color.Black;
// If pass set green else set red
if (e.Value != null)
{
if (e.Value.ToString() == "0")
e.CellStyle.BackColor = System.Drawing.Color.Green;
else
e.CellStyle.BackColor = System.Drawing.Color.Red;
}
else
e.CellStyle.BackColor = System.Drawing.Color.Orange;
}
}
}
I literally have no idea why this is happening or if it is due to the computers not being able to cope with rendering large grid view. Thanks!