2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
SelectionTo 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. 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)); } } } }
VB '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. 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 Sub
Note: Fire the TableControlCurrentCellKeyDown event with in CurrentCellShowingDropDown event.
The following image displays the GridList control with the dropdown grid. 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.