DataGridView - Einzelne Zellen einfärben
-
Hallo,
kann man(bzw. wie kann man) Zellen einfärben?mfg
Mr. X
-
Nimm' das CellPainting-Event
/// <summary> /// Statusklassen zur besseren Sichtbarkeit einfärben /// </summary> private void grdState_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { if (e.ColumnIndex != 2) return; if (e.RowIndex < 0) return; switch ((short)(e.Value)) { case 1: //Produktion e.CellStyle.BackColor = Color.LightSkyBlue; break; case 2: //Rüsten e.CellStyle.BackColor = Color.PaleGreen; break; case 3: //Stillstand e.CellStyle.BackColor = Color.LightPink; break; case 4: //Ausfall e.CellStyle.BackColor = Color.Khaki; break; } }