I would like to change the color of a particular row in my datagridview. The row should be changed to red when the value of columncell 7 is less than the value in columncell 10. Any suggestions on how to accomplish this?
Thanks.
EB
I would like to change the color of a particular row in my datagridview. The row should be changed to red when the value of columncell 7 is less than the value in columncell 10. Any suggestions on how to accomplish this?
Thanks.
EB
You need to loop through the rows in the datagridview and then compare values of columns 7 and 10 on each row.
foreach (GridViewRow gvrow in GridView1.Rows)
{
//Add comparison code here
{
//Change row's color here
}
}
Based in the code you provided, try this:
foreach (GridViewRow row in vendorsDataGridView.Rows)
if (Convert.ToInt32(row.Cells[7].Text) < Convert.ToInt32(row.Cells[10].Text))
{
row.BackColor = Color.Red;
}