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 select the first row by using arrow key when the current selection is in last row and viceversa of WinForms GridListControl?

Platform: WinForms |
Control: GridGroupingControl


To select the first row using arrow key when the current selection is in the last row and viceversa of GridListControl, use TableControlCurrentCellKeyDown event. This handles the key down on the current cell and also 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.


//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.
        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.



'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
Private 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.
         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.
         End If
      End If
   End If
End Sub



Fire the TableControlCurrentCellKeyDown event with in CurrentCellShowingDropDown event.


The following image displays the GridList control with the dropdown grid.

Select the data from dropdown list in GridListControl


C#: SelectionInGridListControl

VB: SelectionInGridListControl

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