GGC Checkbox header in grouped row.

Hi, I would like to add a checkbox in the grouped header of a GGC grid. So when a user click on the checkbox, it will check/uncheck all the checkboxes in a column of that particular group. How can I do that? Many thanks.

2 Replies

AD Administrator Syncfusion Team June 12, 2006 12:37 PM UTC

Hi Kai, To add a checkbox in the grouped rowheader of a grouping grid, you need to change the celltype of the GroupCaptionRowHeaderCell to CheckBox and , handle the TableControlMouseDown event /QueryCellStyleInfo event to achieve the required behaviour. Please find the attachment for more details. Hashtable hash = new Hashtable(); private void gridGroupingControl1_TableControlMouseDown(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlMouseEventArgs e) { Point point = new Point(e.Inner.X,e.Inner.Y); Element element = e.TableControl.PointToNestedDisplayElement(point); GridTableCellStyleInfo style = e.TableControl.PointToTableCellStyle(point); bool isvalue = false; if(element.Kind == DisplayElementKind.Caption && style.TableCellIdentity.ColIndex == 0) { object obj = hash[element.ParentGroup.Category ]; if(obj != null && obj.ToString() != "" ) { bool b = (bool)style.CellValue; isvalue = !b; hash[element.ParentGroup.Category ] = !b; } else { hash[element.ParentGroup.Category ] = false; isvalue = false; } foreach( Record r in element.ParentGroup.Records ) { r.SetValue("show",isvalue); } } } private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) { GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell; if(e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Caption && e.TableCellIdentity.ColIndex == 0 && e.TableCellIdentity.RowIndex > 2) { object obj =hash[e.TableCellIdentity.DisplayElement.ParentGroup.Category ]; if(obj != null && obj.ToString() != "") { bool b = (bool)obj; e.Style.CellValue = b; } } } Here is a sample. http://www.syncfusion.com/Support/user/uploads/CaptionCheckbox_9458c88.zip Let me know if this helps. Best Regards, Haneef


KA Kai June 13, 2006 10:20 AM UTC

It does indeed work! Many thanks. >Hi Kai, > >To add a checkbox in the grouped rowheader of a grouping grid, you need to change the celltype of the GroupCaptionRowHeaderCell to CheckBox and , handle the TableControlMouseDown event /QueryCellStyleInfo event to achieve the required behaviour. Please find the attachment for more details. > >Hashtable hash = new Hashtable(); >private void gridGroupingControl1_TableControlMouseDown(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlMouseEventArgs e) >{ > Point point = new Point(e.Inner.X,e.Inner.Y); > Element element = e.TableControl.PointToNestedDisplayElement(point); > GridTableCellStyleInfo style = e.TableControl.PointToTableCellStyle(point); > bool isvalue = false; > > if(element.Kind == DisplayElementKind.Caption && style.TableCellIdentity.ColIndex == 0) > { > object obj = hash[element.ParentGroup.Category ]; > if(obj != null && obj.ToString() != "" ) > { > bool b = (bool)style.CellValue; > isvalue = !b; > hash[element.ParentGroup.Category ] = !b; > > } > else > { > hash[element.ParentGroup.Category ] = false; > isvalue = false; > } > foreach( Record r in element.ParentGroup.Records ) > { > r.SetValue("show",isvalue); > } > > } >} > > >private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) >{ > GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell; > if(e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Caption && e.TableCellIdentity.ColIndex == 0 && e.TableCellIdentity.RowIndex > 2) > { > object obj =hash[e.TableCellIdentity.DisplayElement.ParentGroup.Category ]; > if(obj != null && obj.ToString() != "") > { > bool b = (bool)obj; > e.Style.CellValue = b; > } > } >} > >Here is a sample. >http://www.syncfusion.com/Support/user/uploads/CaptionCheckbox_9458c88.zip > >Let me know if this helps. >Best Regards, >Haneef

Loader.
Up arrow icon