Mohammad Imran

Mohammad Imran

  • NA
  • 40
  • 10k

Cell color not changing based on condition..

Aug 22 2017 12:48 AM
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)