Hi Santhosh,
Thank you for your interest in Syncfusion products.
If you want to detect the check box state, you need to assign its state by using CheckBoxOptions property. And you can get check box state by using its CellValue. Please make use of below code,
this.gridControl1.ColStyles[1].CellType = GridCellTypeName.CheckBox;
this.gridControl1.ColStyles[1].CheckBoxOptions = new GridCheckBoxCellInfo("true", "false", "", true);
this.gridControl1.ColStyles[1].CellValue = true;
this.gridControl1.CheckBoxClick += new GridCellClickEventHandler(gridControl1_CheckBoxClick);
void gridControl1_CheckBoxClick(object sender, GridCellClickEventArgs e)
{
if(this.gridControl1[e.RowIndex,e.ColIndex].CellValue=="true")
MessageBoxAdv.Show("Checked state");
else
MessageBoxAdv.Show("UnChecked state");
}
Please let me know if you have any concerns.
Regards,
Neelakandan
Hi Santhosh,
Thank you for your update.
If you want to change the check box state using SpaceBar key, you can use CurrentCellKeyDown event to customize your scenario. Please make use of below code and attached sample,
this.gridControl1.CurrentCellKeyDown += new KeyEventHandler(gridControl1_CurrentCellKeyDown);
void gridControl1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Space)
{
if (this.gridControl1[this.gridControl1.CurrentCell.RowIndex, this.gridControl1.CurrentCell.ColIndex].CellType == GridCellTypeName.CheckBox)
{
if (this.gridControl1[this.gridControl1.CurrentCell.RowIndex, this.gridControl1.CurrentCell.ColIndex].CellValue == true.ToString())
{
this.gridControl1[this.gridControl1.CurrentCell.RowIndex, this.gridControl1.CurrentCell.ColIndex].CellValue = false;
}
else if (this.gridControl1[this.gridControl1.CurrentCell.RowIndex, this.gridControl1.CurrentCell.ColIndex].CellValue==false.ToString())
this.gridControl1[this.gridControl1.CurrentCell.RowIndex, this.gridControl1.CurrentCell.ColIndex].CellValue = true;
}
}
}
Please let me know if you have any concerns.
Regards,
Neelakandan