Articles in this section

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

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, use the CurrentCell.The ShowDropDown method is used in the CurrentCellKeyPress event.


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();
    }
}
AddHandler Me.gridControl1.CurrentCellKeyPress, AddressOf Me.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.

Conclusion

I hope you enjoyed learning about how to show the dropdown list when a key is pressed in the ComboBox cell in WinForms GridControl.


You can refer to our WinForms GridControl feature tour page to know about its other groundbreaking feature representations and WinForms GridControl 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!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied