Articles in this section
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:

Move one control to another using Tab key

Samples:

C#: Move one control to another

VB: Move one control to another

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied