In a simple .NET WinForm I have a datagridview
that is being color painted based on the value of cells. The code is working, but the rendered form is "shaky" (that look when a computer is constantly having to redraw and can't keep up). I am wondering if there's something I can do to eliminate this, or if there's something wrong with my code. Advice appreciated.
private void gvPhoneQueue_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
try
{
if (gvPhoneQueue.Columns[e.ColumnIndex].HeaderText == "CallsWaiting")
{
string convertedVal = e.Value.ToString();
if (Convert.ToInt32(convertedVal) > _greenTolerance)
{
gvPhoneQueue.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Green;
}
if (Convert.ToInt32(convertedVal) > _yellowTolerance)
{
gvPhoneQueue.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Yellow;
}
if (Convert.ToInt32(convertedVal) > _redTolerance)
{
gvPhoneQueue.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Red;
}
}
}
catch (System.Exception ex)
{
LogEvent("Error" _+ ex);
}
}