Articles in this section
Category / Section

How to show the dropdown list when a key is pressed in the ComboBox cell in WinForms GridControl?

2 mins read

Dropdown list in grid

By default, the dropdown list is shown when the mouse is clicked on the dropdown button of the ComboBox cell. To show the dropdown list when any key is pressed in the ComboBox cell, the CurrentCell.ShowDropDown() method is used in the CurrentCellKeyPress event.

C#

this.gridControl1.CurrentCellKeyPress += new KeyPressEventHandler(gridControl1_CurrentCellKeyPress);
void gridControl1_CurrentCellKeyPress(object sender, KeyPressEventArgs e)
{         
    //Checks whether the cell type is ComboBox or not.
    if (this.gridControl1[this.gridControl1.CurrentCellInfo.RowIndex, this.gridControl1.CurrentCellInfo.ColIndex].CellType == GridCellTypeName.ComboBox)
    {
        //Enables the show dropdown in the current cell.
        this.gridControl1.CurrentCell.ShowDropDown();
    }
}

 

VB

Private Me.gridControl1.CurrentCellKeyPress += New KeyPressEventHandler(AddressOf gridControl1_CurrentCellKeyPress)
Private Sub gridControl1_CurrentCellKeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs)
  'Checks whether the cell type is ComboBox or not.
  If Me.gridControl1(Me.gridControl1.CurrentCellInfo.RowIndex, Me.gridControl1.CurrentCellInfo.ColIndex).CellType Is GridCellTypeName.ComboBox Then
    'Enables the show dropdown in the current cell.
    Me.gridControl1.CurrentCell.ShowDropDown()
  End If
End Sub

 

After applying the properties, the Grid looks like the following screenshot.

Dropdown list values entered into grid cell

Note:

Only the dropdown list values should be entered, otherwise, the dropdown is not shown.

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