How to select the first row by using arrow key in WinForms GridGroupingControl?
Selection
To select the first row using arrow key when the current selection is in the last row and vice versa of WinForms GridListControl, use TableControlCurrentCellKeyDown event. This handles the key down on the current cell and invokes the CurrentCellShowingDropDown event as the GridList control displays the dropdown grid to select the records.
In the given sample, the GridList control is added as a column for the grid grouping control.
C#
//Sets the CellType and data source for gridlistcontrol.
this.gridGroupingControl1.TableDescriptor.Columns[3].Appearance.AnyRecordFieldCell.CellType = GridCellTypeName.GridListControl;
this.gridGroupingControl1.TableDescriptor.Columns[3].Appearance.AnyRecordFieldCell.DataSource = countries;
this.gridGroupingControl1.TableDescriptor.Columns[3].Appearance.AnyRecordFieldCell.ValueMember = "CountryCode";
//Hooks the event in TableControl_CurrentCellShowingDropDown event
this.gridGroupingControl1.TableControlCurrentCellKeyDown += gridGroupingControl1_TableControlCurrentCellKeyDown;
void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlKeyEventArgs e)
{
//Gets the Currentcell rendere as the drop down gridlistcontrol renderer.
GridDropDownGridListControlCellRenderer rend = e.TableControl.CurrentCell.Renderer as GridDropDownGridListControlCellRenderer;
if (rend != null)
{
GridControl grid = rend.ListControlPart.Grid as GridControl;
if (e.Inner.KeyCode == Keys.Down)
{
if (grid.CurrentCell.HasCurrentCellAt(grid.RowCount))
{
//Moves the selection to first record.
grid.CurrentCell.MoveTo(GridRangeInfo.Row(0));
}
}
if (e.Inner.KeyCode == Keys.Up)
{
if (!grid.CurrentCell.IsActive)
grid.CurrentCell.MoveTo(1, 0);
if (grid.CurrentCell.HasCurrentCellAt(1))
{
//moves the selection to last record.
grid.CurrentCell.MoveTo(GridRangeInfo.Row(grid.RowCount));
}
}
}
}'Sets the CellType and data source for gridlistcontrol
Me.gridGroupingControl1.TableDescriptor.Columns(3).Appearance.AnyRecordFieldCell.CellType = GridCellTypeName.GridListControl
Me.gridGroupingControl1.TableDescriptor.Columns(3).Appearance.AnyRecordFieldCell.DataSource = countries
Me.gridGroupingControl1.TableDescriptor.Columns(3).Appearance.AnyRecordFieldCell.ValueMember = "CountryCode"
'Hooks the event in TableControl_CurrentCellShowingDropDown event
AddHandler Me.gridGroupingControl1.TableControlCurrentCellKeyDown, AddressOf gridGroupingControl1_TableControlCurrentCellKeyDown
Private Sub gridGroupingControl1_TableControlCurrentCellKeyDown(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlKeyEventArgs)
'Gets the Currentcell rendere as the drop down gridlistcontrol renderer.
Dim rend As GridDropDownGridListControlCellRenderer = TryCast(e.TableControl.CurrentCell.Renderer, GridDropDownGridListControlCellRenderer)
If rend IsNot Nothing Then
Dim grid As GridControl = TryCast(rend.ListControlPart.Grid, GridControl)
If e.Inner.KeyCode = Keys.Down Then
If grid.CurrentCell.HasCurrentCellAt(grid.RowCount) Then
'Moves the selection to first record.
grid.CurrentCell.MoveTo(GridRangeInfo.Row(0))
End If
End If
If e.Inner.KeyCode = Keys.Up Then
If Not grid.CurrentCell.IsActive Then
grid.CurrentCell.MoveTo(1, 0)
End If
If grid.CurrentCell.HasCurrentCellAt(1) Then
'moves the selection to last record.
grid.CurrentCell.MoveTo(GridRangeInfo.Row(grid.RowCount))
End If
End If
End If
End SubFire the TableControlCurrentCellKeyDown event with in CurrentCellShowingDropDown event.
The following image displays the GridListControl with the dropdown grid.

Samples:
C#: SelectionInGridListControl
VB: SelectionInGridListControl
Conclusion
I hope you enjoyed learning about how to select the first row by using arrow key when the current selection is in last row and vice versa of GridListControl.
You can refer to our WinForms GridGroupingControl feature tour page to know about its other groundbreaking feature representations and WinForms GridGroupingControl documentation, and how to quickly get started for configuration specifications.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!