Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone....
I have a datagridview where one checkbox column is there and i have added a header checkbox.
My code for adding a header checkbox and checkbox column is
DataGridViewCheckBoxColumn c1;
CheckBox ckBox;
private void CheckboxSelect_Load(object sender, EventArgs e)
{
c1 = new DataGridViewCheckBoxColumn();

c1.Name = "selection";

c1.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;

this.dgvSelectAll.Columns.Add(c1);

this.dgvSelectAll.Rows.Add();

this.dgvSelectAll.Rows.Add();

this.dgvSelectAll.Rows.Add();

this.dgvSelectAll.Rows.Add();

ckBox = new CheckBox();

Rectangle rect =this.dgvSelectAll.GetCellDisplayRectangle(0, -1, true);

ckBox.Size = new Size(18, 18);

ckBox.Location = rect.Location;

this.dgvSelectAll.Controls.Add(ckBox);
}

Is it possible If All check boxes are checked then header Checkbox will be checked and among them (Selected Check boxes)one is unchecked then header will be unchecked ??

Thank You
Posted

1 solution

 
Share this answer
 
Comments
krushna chandra jena 26-Sep-12 8:11am    
My problem is in Windows Desktop Application ....So please provide another solution regarding windows based .
I have gone through
http://www.codeproject.com/Articles/42437/Toggling-the-States-of-all-CheckBoxes-Inside-a-Dat#3
but here i got an exception and could not overcome that problem , that's why i need another solution ..Please help

Thank You

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