tags:

views:

220

answers:

1

Hi, GUYS,

I am trying to highlight the specified row in DataGridView, but it is not working by the following code i wrote, any one has idea? Thanks !!!

foreach (DataGridViewRow row in DataGridView1.Rows)
        {
            if (row.Cells["Job No"].Value.ToString().Equals("Sub Total"))
            {

                row.DefaultCellStyle.BackColor = Color.Red;

            }

        }
A: 
foreach (DataGridViewRow row in DataGridView1.Rows) 
{ 
    if (row.Cells["Job No"].Value.ToString().Equals("Sub Total")) 
    { 
        DataGridView1.rows[row.index].DefaultCellStyle.BackColor = Color.Red; 
    } 
} 
Yasien