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.
Unfortunately, activation email could not send to your email. Please try again.

Checkbox state change

Thread ID:

Created:

Updated:

Platform:

Replies:

117590 Nov 13,2014 12:31 AM Nov 16,2014 11:37 PM Windows Forms 3
loading
Tags: GridControl
Santhosh BJ
Asked On November 13, 2014 12:31 AM

Hi,

I am using syncfusion gridcontrol in which one column is checkbox. There is CheckboxClick event. But it is not coming for when we check checkbox by space key.  We can use currentcellchanged but it rises for all column change. Is there any event specific to gridcontrolcheckboxstate change ? I am using Syncfusion.Windows.Forms.Grid.GridControl.

Regards,
BJ

Neelakandan Kannan [Syncfusion]
Replied On November 13, 2014 06:06 AM

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


Santhosh BJ
Replied On November 13, 2014 06:55 AM

Will it work for the scenario where checkbox is checked by using spacebar key ?


Regards,
Santhosh BJ

Neelakandan Kannan [Syncfusion]
Replied On November 16, 2014 11:37 PM

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


Attachment: Sample_CheckBox_Demo_613d91d6.zip

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;