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