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 skip deleting the cell text of an exclusive ComboBox cell in WinForms GridControl?

Platform: WinForms |
Control: GridControl

Skip the deleting cell in grid

When you set the ComboBox in a Grid and assign the dropdown style as exclusive, the cell text is removed from the ComboBox cell while pressing delete key or backspace key.


To overcome this problem, you can use the CurrentCellKeyDown event to handle the Delete & BackSpace keys.


// On Form load
this.gridControl1.CurrentCellKeyDown += new KeyEventHandler(gridControl1_CurrentCellKeyDown);
void gridControl1_CurrentCellKeyDown(object sender, KeyEventArgs e)
   GridCurrentCell cc = this.gridControl1.CurrentCell;
   if (cc.Renderer.StyleInfo.CellType == "ComboBox" && cc.Renderer.StyleInfo.DropDownStyle == GridDropDownStyle.Exclusive)
      // Pressing delete key or backspacekey
      if (e.KeyCode == Keys.Back || e.KeyCode == Keys.Delete)
         // not remove the cell content
         e.Handled = true;


‘On Form load
AddHandler gridControl1.CurrentCellKeyDown, AddressOf gridControl1_CurrentCellKeyDown
' to perform action while pressing key
Private Sub gridControl1_CurrentCellKeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
    Dim cc As GridCurrentCell = Me.gridControl1.CurrentCell
    If cc.Renderer.StyleInfo.CellType Is "ComboBox" AndAlso  cc.Renderer.StyleInfo.DropDownStyle = GridDropDownStyle.Exclusive Then
      ' Pressing delete key or backspacekey
      If e.KeyCode = Keys.Back OrElse e.KeyCode = Keys.Delete Then
        ' not remove the cell content
        e.Handled = True
      End If
    End If
End Sub


C#: DropdownStyle.Exclusive_C#.zip

VB: DropdownStyle.Exclusive_VB.zip

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