We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Work with checkbox column in GridGroupingControl


------
gridGroupingControl1.TableDescriptor.Columns[i].Appearance.AnyRecordFieldCell.CellType = GridCellTypeName.CheckBox;
------
I have a gridgroupingcontrol which have checkbox column , four column READ,WRITE,UPDATE,DELETE have int value 

How i can click on checkbox, then set the value of this column , example : no check = 0 , checked = 1, i can not checked when click on this checkbox

How to add a checkbox on header column of READ,WRITE,UPDATE,DELETE, when checked on that check box , all of checbox in that column will be checked

Thank for your help !

1 Reply

PM Piruthiviraj Malaimelraj Syncfusion Team December 8, 2016 01:03 PM UTC

Hi Truong, 
 
Thanks for your interest in Syncfusion products. 
 
We have analyzed your scenario and created the simple sample. To use the checkbox in column header and changed the check state dynamically, QueryCellStyleInfo, SaveCellText events can be used and changed the check state for whole column based on column header_ checkbox , TableControlCheckBoxClick event can be used. In order to change the “True” and “False” values as you wanted, CheckBoxOptions property can be used. Please make use of the below code, 
 
Code example: 
object cellValue = "0"; 
this.gridGroupingControl1.QueryCellStyleInfo += new GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo); 
this.gridGroupingControl1.SaveCellText += new Syncfusion.Windows.Forms.Grid.GridCellTextEventHandler(gridGroupingControl1_SaveCellText); 
 
void gridGroupingControl1_SaveCellText(object sender, Syncfusion.Windows.Forms.Grid.GridCellTextEventArgs e) 
{ 
    GridTableCellStyleInfo style = (GridTableCellStyleInfo)e.Style; 
    if (style.Enabled && style.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell) 
    { 
        cellValue = e.Text; 
        e.Handled = true; 
    } 
} 
 
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) 
{ 
    if (e.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell && e.TableCellIdentity.Column.Name == "Column2") 
    { 
        e.Style.CellType = "CustomCheckBox"; 
        e.Style.CellValue = cellValue; 
     //To set '1' and '0' instead of "True" and "False" 
        e.Style.CheckBoxOptions = new GridCheckBoxCellInfo("1", "0", "", true); 
        e.Style.ReadOnly = false; 
        e.Style.Enabled = true; 
    } 
 
    e.Handled = true; 
} 
 
Sample link: 
 
Please refer to below KB for further references, 
 
Regards, 
Piruthiviraj

Loader.
Up arrow icon