Category / Section
How to move one control to another by using the TAB key in the WinForms GridGroupingControl?
2 mins read
Move one control to another using Tab key
When the TAB key is pressed at the end of the cell, the control that needs to be moved is moved to another control by using the TableControlCurrentCellKeyDown event and the SelectNextControl method.
C#
this.gridGroupingControl1.TableControlCurrentCellKeyDown += gridGroupingControl1_TableControlCurrentCellKeyDown; void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlKeyEventArgs e) { int row, col; row = e.TableControl.CurrentCell.RowIndex; col = e.TableControl.CurrentCell.ColIndex; if (this.gridGroupingControl1.TableModel.RowCount == row && this.gridGroupingControl1.TableModel.ColCount == col + 2) { if (e.Inner.KeyCode == Keys.Tab) { //Moves one control to another control. this.SelectNextControl(gridGroupingControl1, true, false, false, false); } } }
VB
Private Me.gridGroupingControl1.TableControlCurrentCellKeyDown += AddressOf gridGroupingControl1_TableControlCurrentCellKeyDown Private Sub gridGroupingControl1_TableControlCurrentCellKeyDown(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlKeyEventArgs) Dim row, col As Integer row = e.TableControl.CurrentCell.RowIndex col = e.TableControl.CurrentCell.ColIndex If Me.gridGroupingControl1.TableModel.RowCount = row AndAlso Me.gridGroupingControl1.TableModel.ColCount = col + 2 Then If e.Inner.KeyCode = Keys.Tab Then 'Moves one control to another control. Me.SelectNextControl(gridGroupingControl1, True, False, False, False) End If End If End Sub
The following screenshot displays the Grid after the properties are applied:
Samples: