)
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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Platform: WinForms |
Control: GridControl |
Published Date: April 21, 2015 |
Last Revised Date: December 19, 2019

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.

 

Samples:

C#: Dropdown

VB: Dropdown

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
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
Live Chat Icon