Hi Kartheechidambaram,
We need to reset the color of the rows in the ColumnHeaderMouseClick event handler. This is a code snippet:
private void dataGridView1_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
//Reset the row color.
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if(IsSetYellow(row))
row.DefaultCellStyle.BackColor = Color.Yellow;
}
}
private bool IsSetYellow(DataGridViewRow view)
{
//Write code here to check and return if the row needs to be colored.
return true;
}
Regards,
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.