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

How to use the CheckBoxClick event when the CheckBox state changes by space key in WinForms GridControl?

Platform: WinForms |
Control: GridControl


In the GridControl, by default CheckBoxClick event is raised, when you change the CheckBox state on Mousecklick. On using the space key, the CheckBox state is changed, but the CheckBoxClick event is not fired. To resolve this, the CheckBoxClick event can be manually raised by using the RaiseCheckBoxClick method. This method is called by using the CurrentCellKeyDown event.

The following code example is for calling the CheckBoxClick event in the CurrentCellKeyDown event.


// Hooks the CheckBoxClick event
this.gridControl1.CheckBoxClick += new GridCellClickEventHandler(gridControl1_CheckBoxClick);
// Hooks the CurrentCellKeyDown event
this.gridControl1.CurrentCellKeyDown += new KeyEventHandler(gridControl1_CurrentCellKeyDown);
void gridControl1_CurrentCellKeyDown(object sender, KeyEventArgs e)
    // validates the Key pressed.
    if (e.KeyCode == Keys.Space)
        GridCurrentCell cc=this.gridControl1.CurrentCell ;
        if (this.gridControl1[this.gridControl1.CurrentCell.RowIndex, this.gridControl1.CurrentCell.ColIndex].CellType == GridCellTypeName.CheckBox)
            //Raises the CheckBoxClick event.
            this.gridControl1.RaiseCheckBoxClick(cc.RowIndex, cc.ColIndex, MouseEventArgs.Empty as MouseEventArgs);
void gridControl1_CheckBoxClick(object sender, GridCellClickEventArgs e)



' Hooks the CheckBoxClick event
AddHandler gridControl1.CheckBoxClick, AddressOf gridControl1_CheckBoxClick
' Hooks the CurrentCellKeyDown event
AddHandler gridControl1.CurrentCellKeyDown, AddressOf gridControl1_CurrentCellKeyDown
Private Sub gridControl1_CurrentCellKeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
 'validates the Key pressed.
 If e.KeyCode = Keys.Space Then
  Dim cc As GridCurrentCell=Me.gridControl1.CurrentCell
  If Me.gridControl1(Me.gridControl1.CurrentCell.RowIndex, Me.gridControl1.CurrentCell.ColIndex).CellType Is GridCellTypeName.CheckBox Then
   'Raises the CheckBoxClick event.
   Me.gridControl1.RaiseCheckBoxClick(cc.RowIndex, cc.ColIndex, TryCast(MouseEventArgs.Empty, MouseEventArgs))
  End If
 End If
End Sub
Private Sub gridControl1_CheckBoxClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
End Sub



Here MouseEventArgs are passed as Empty to the CheckBoxClick event. So, in this case, you can’t use mouse arguments inside the CheckBoxClick event.



C#: CheckBoxClickEvent_C#

VB: CheckBoxClickEvent_VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon 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.Close Icon

Live Chat Icon For mobile