Click here to Skip to main content
15,891,597 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi fellows. I have a DataGridView control with a CheckBoxColumn in it, and a CheckBox on the Header. There are some articles regarding this topic , but, i want the DataGridView to behave like i said in the Subject, like yahoo or gmail when you select the checkbox of an email and the corresponding row gets selected too.Does anyone have some clues regarding this?

Thanks in advance!!!
Posted
Comments
Sergey Alexandrovich Kryukov 24-Jan-13 16:13pm    
What did you try? It looks trivial, as the selecting/selected events are available.
—SA

1 solution

U can use below on form load event
C#
DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn();
chk.HeaderText = "Check Data";
chk.Name = "chk";
dataGridView1.Columns.Add(chk);

then on to change coor on checkbox click put code on cellmouseclick.
C#
if (dataGridView1.Rows[e.RowIndex].Cells["chk"].Value == true)
{
       for(int i=0;i < dataGridView1.Rows[e.RowIndex].Cells.Count; i++)
       {
            dataGridView1.Rows[e.RowIndex].Cells[i].Style.BackColor = Color.Green;
       }
}

hope it helps u out.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900