Hi mostafasalama145,
You need to execute FOR EACH loop through the DataGridView rows and perform check.
Code
private void Form1_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[2] { new DataColumn("Num1", typeof(int)), new DataColumn("Num2", typeof(int)) });
dt.Rows.Add(51, 62);
dt.Rows.Add(45, 24);
dt.Rows.Add(66, 02);
dt.Rows.Add(24, 78);
dt.Rows.Add(78, 69);
dt.Rows.Add(44, 33);
dataGridView1.DataSource = dt;
foreach (DataGridViewRow row in dataGridView1.Rows)
{
int value1 = Convert.ToInt32(row.Cells[0].Value);
int value2 = Convert.ToInt32(row.Cells[1].Value);
if (value1 > value2 )
{
row.Cells[1].Style.BackColor = Color.Red;
}
else
{
row.Cells[0].Style.BackColor = Color.Red;
}
}
}
Screenshot