Good day! I have a DataGridView, Inside the DataGridView they have 2 types font text color that is color black and color red. Please see the image below.
Now I want is! If I double click the row where the font text color black means read only. But! if I double click the row where the font text is color red it's show a message.
I have a code here but it's not work for me.
1st attempt code:
private void dataGridView2_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
{
foreach (DataGridViewRow row in dataGridView2.Rows)
{
if (row.DefaultCellStyle.ForeColor == Color.Black)
{
//
}
else if (row.DefaultCellStyle.ForeColor != Color.Black)
{
MessageBox.Show("red");
}
break;
}
}
2nd attempt code:
private void dataGridView2_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
{
foreach (DataGridViewRow row in dataGridView2.Rows)
{
var now = DateTime.Now;
var cellDate = DateTime.Parse(row.Cells[12].Value.ToString());
if (now < cellDate)
{
//row.DefaultCellStyle.BackColor = Color.Red;
MessageBox.Show("color red");
}
}
}
Both of this attempt 1and 2 is not work for me.