private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Completed") { e.CellStyle.BackColor = Color.Green; } }
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (e.Value is bool) { e.Value = ((bool)e.Value) ? "Yes" : "No"; e.FormattingApplied = true; } else if (e.Value is DateTime) { e.Value = ((DateTime)e.Value).ToShortDateString(); e.FormattingApplied = true; } }The System.Windows.Forms.DataGridViewCellFormattingEventArgs class is part of the System.Windows.Forms package library.