estoy pintando mis filas de un DataGridView como esto:C color de fondo # WinForms DataGridView haciendo demasiado lento
private void AdjustColors()
{
foreach (DataGridViewRow row in aufgabenDataGridView.Rows)
{
AufgabeStatus status = (AufgabeStatus)Enum.Parse(typeof(AufgabeStatus), (string)row.Cells["StatusColumn"].Value);
switch (status)
{
case (AufgabeStatus.NotStarted):
row.DefaultCellStyle.BackColor = Color.LightCyan;
break;
case (AufgabeStatus.InProgress):
row.DefaultCellStyle.BackColor = Color.LemonChiffon;
break;
case (AufgabeStatus.Completed):
row.DefaultCellStyle.BackColor = Color.PaleGreen;
break;
case (AufgabeStatus.Deferred):
row.DefaultCellStyle.BackColor = Color.LightPink;
break;
default:
row.DefaultCellStyle.BackColor = Color.White;
break;
}
}
}
Entonces me llaman en el método OnLoad:
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
AdjustColors();
}
prefiero OnLoad a OnPaint o algo así porque OnPaint se llama con mucha frecuencia.
La pregunta: ¿Por qué tarda aproximadamente 100 - 200 ms para cambiar el fondo de cada fila? Temprano, estaba doint CellPaint .. pero tuve problemas al desplazarme con refrescante ..
Te refieres toma 100 - 200ms por fila? Eso suena bastante pesado. – leppie
¿Cuántas filas? ¿Tiene doble buffer en el formulario? ¿Has intentado utilizar el evento CellFormatting? – stuartd