Home Forums WinForms controls Xceed Grid for WinForms Catching certain keys Reply To: Catching certain keys

Xceed Support
Member
Post count: 5658

In order to trap the Tab (and shift-tab) keys in the OnKeyDown/OnKeyUp method you need to override the IsInputKey method to tell the grid that the tab key is a key that the grid will handle. So in the IsInputKey method, check if the Tab key is pressed (keyData.Tab or Keys.Shift Or Keys.Tab if the shift-tab keys were pressed) and return true (don’t forget to call Base if you have nothing to do with the key!).

Because IsInputKey returns true when the tab key is pressed, the OnKeyDown and OnKeyUp methods will then be called and you can do the handling you want in there.

As for ProcessCmdKey, it is normally used to handle the Enter and the Escape key. If you want to handle the Tab from there, you can check if the Tab key was pressed (as well as the Shift key) in the keyData parameter. ( (keyData And Keys.KeyCode) will give you the keyCode, (keyData and Keys.Modifiers) Will give you the modifiers keys (alt,ctrl … etc))

I hope this helps!

Imported from legacy forums. Posted by Jenny [Xceed] (had 760 views)