7
Answers

Cell color not changing based on condition..

Below code is not working.not changing color.. data type is datetime..
 
 
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{

if (e.ColumnIndex == 6)
{

var mydatetime = DateTime.Parse(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());

if (mydatetime.Hour > 9 && mydatetime.Minute > 30)
{
e.CellStyle.BackColor = Color.Yellow;

}
}
}
Answers (7)