User (Old forums)MemberAugust 29, 2003 at 4:16 amPost count: 23064
I have created a class that inherits from the Xceed.Grid.GridControl and that overrides certain methods like OnKeyDown. With OnKeyDown I can catch most of the keys I need, and I can see if Ctrl, Shift or Alt has been pressed, so I can make the difference between Ctrl+C, Ctrl+Shift+C, Ctrl+Alt+C, etc…
I would also like to catch Tab and Shift+Tab, but pressing Tab won’t call OnKeyDown or OnKeyUp. So I’ve tried overriding ProcessCmdKey, which catches the Tab-button. But ProcessCmdKey doesn’t say anything about the state of Ctrl, Shift and Alt.
With ProcessCmdKey, I can catch the Tab-key, but how can I also catch Shift+Tab? And can I prevent the GridControl from losing focus when pressing Tab?
Imported from legacy forums. Posted by Tommy (had 5140 views)Xceed SupportMemberAugust 29, 2003 at 10:56 amPost 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)User (Old forums)MemberAugust 29, 2003 at 11:20 amPost count: 23064
Thank you for the reply. I tried it, and the Tab-key is now caught by OnKeyDown. The code is executed like it should (more or less), but because IsInputKey returns true, the CellEditor of the current cell is activated when I press the Tab-key. Can this be suppressed?
Imported from legacy forums. Posted by Tommy (had 463 views)Xceed SupportMemberAugust 29, 2003 at 11:42 amPost count: 5658
It is possible that some of the editors handle the Tab key in their implementation of IsInputKey. Can you tell me with which cell editors you are experiencing this behavior?
Imported from legacy forums. Posted by Jenny [Xceed] (had 598 views)User (Old forums)MemberAugust 30, 2003 at 6:43 amPost count: 23064
I’m using a custom editor that implements the ICellEditor-interface, and inherits from System.Windows.Forms.TextBox. I’ll try and catch the Tab-key in the implemented IsInputKey-method. Thank you.
Imported from legacy forums. Posted by Tommy (had 6243 views)
- You must be logged in to reply to this topic.