)
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 suppress KeyDown event in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: May 13, 2016 |
Last Revised Date: February 12, 2020
Tags: events

Suppress KeyDown event

In order to suppress the key down event, the SuppressKeyPress property in TableControlCurrentCellKeyDown event can be used. Then overriding of ProcessCmdKey() method gets the keys data.

C#

// form
// Trigger the required event.
gridGroupingControl1.TableControlCurrentCellKeyDown += gridGroupingControl1_TableControlCurrentCellKeyDown;
 
void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, GridTableControlKeyEventArgs e)
{
      e.Inner.SuppressKeyPress = true;
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
   Keys keyCode = keyData & Keys.KeyCode;
   switch (keyCode)
   {
      case Keys.Down: MessageBox.Show("KeyDown Event suppressed");
              break;
      case Keys.Up: MessageBox.Show("KeyDown Event suppressed");
              break;
      case Keys.Right: MessageBox.Show("KeyDown Event suppressed");
              break;
      case Keys.Left: MessageBox.Show("KeyDown Event suppressed");
              break;
      case Keys.PageUp: MessageBox.Show("KeyDown Event suppressed");
              break;
      case Keys.PageDown: MessageBox.Show("KeyDown Event suppressed");
              break; 
  }
   return base.ProcessCmdKey(ref msg, keyData);
}

VB

' form()
' Trigger the required event. 
Private gridGroupingControl1.TableControlCurrentCellKeyDown += AddressOf gridGroupingControl1_TableControlCurrentCellKeyDown
Private Sub gridGroupingControl1_TableControlCurrentCellKeyDown(ByVal sender As Object, ByVal e As GridTableControlKeyEventArgs)
      e.Inner.SuppressKeyPress = True
   End If
End Sub
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
   Dim keyCode As Keys = keyData And Keys.KeyCode
   Select Case keyCode
       Case Keys.Down MessageBox.Show("KeyDown Event suppressed")
                break
       Case Keys.Up MessageBox.Show("KeyDown Event suppressed")
                break
       Case Keys.Right MessageBox.Show("KeyDown Event suppressed")
                break
       Case Keys.Left MessageBox.Show("KeyDown Event suppressed")
                break
       Case Keys.PageUp MessageBox.Show("KeyDown Event suppressed")
                break
       Case Keys.PageDown MessageBox.Show("KeyDown Event suppressed")
                break
   End Select
   Return MyBase.ProcessCmdKey(msg, keyData)
End Function

Screenshot

Show the keydown event suppressed

Samples:

C#: SuppressKeyDown_CS

VB: SuppressKeyDown_VB

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