private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (this.dataGridView1.Columns[e.ColumnIndex].DataPropertyName == "return_date") { var returnDate = Convert.ToDateTime(dataGridView1.Rows[e.RowIndex].Cells["return_date"].Value); var borrowDate = Convert.ToDateTime(dataGridView1.Rows[e.RowIndex].Cells["borrow_date"].Value); if (returnDate > borrowDate) { e.CellStyle.BackColor = Color.Red; // e.CellStyle.ForeColor = Color.Red; } } }
if(e.row.cells[return_date ColumnNo].text > e.row.cells[borrow_date ColumnNo].text) { // set background colour }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)