2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
EventsIn 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. C# // 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) { Debugger.Break(); }
VB ' 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) Debugger.Break() End Sub
Note: Here MouseEventArgs are passed as Empty to the CheckBoxClick event. So, in this case, you can’t use mouse arguments inside the CheckBoxClick event.
Samples: |
2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.