change the colour of a row of a datagridview at page load

Nov 17 2009 4:31 AM

hai expert...................
I want to chage the colour of a particular row at load time..The form is loaded on MDI parent...I have used the following code...
dataGridView1.DataSource = dt;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (Convert.ToString(dataGridView1.Rows[i].Cells[1].Value) == "OPENING BALANCE")
{
dataGridView1.Rows[i].DefaultCellStyle.BackColor =
Color.AliceBlue;
dataGridView1.Rows[i].DefaultCellStyle.ForeColor =
Color.Red;
}
}
Please help me...............

Answers (3)