void Grid_CustomCellStyle(object sender, CustomCellStyleEventArgs e) { if (e.FieldName == nameof(EmployeeTask.Name) || e.FieldName == nameof(EmployeeTask.DueDate)) { if (((EmployeeTask)e.Item).Completed) { e.TextDecorations = TextDecorations.Strikethrough; e.FontColor = new Color(e.FontColor.R, e.FontColor.G, e.FontColor.B, 0.5); } } }
void DataGridView_CustomCellStyle(object sender, CustomCellStyleEventArgs e) { if (e.RowHandle % 2 == 0) { e.BackgroundColor = GetColorFromResource("GridCustomAppearanceOddRowBackgroundColor"); } e.FontColor = GetColorFromResource("GridCustomAppearanceFontColor"); if (e.FieldName == "ActualSales" || e.FieldName == "TargetSales") { double value = (double)dataGridView.GetCellValue(e.RowHandle, e.FieldName); if (value > 7000000) { e.FontColor = GetColorFromResource("GridCustomAppearancePositiveFontColor"); } else if (value < 4000000) { e.FontColor = GetColorFromResource("GridCustomAppearanceNegativeFontColor"); } } }