private void dataGridViewX1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (iii == 1) { if ((bool)dataGridViewX1.CurrentRow.Cells[0].Value) dataGridViewX1.CurrentRow.DefaultCellStyle.BackColor = Color.Red; else dataGridViewX1.CurrentRow.DefaultCellStyle.BackColor = Color.Green; } }