How to exit grid with ctrl-TAB when grid is on a tabpage (onkeydown works when grid not on tabpage)

Posted by Charles Hankey on Stack Overflow See other posts from Stack Overflow or by Charles Hankey
Published on 2010-06-02T00:51:29Z Indexed on 2010/06/02 0:53 UTC
Read the original article Hit count: 286

Filed under:
|
|
|
|

winforms .net 3.5 Ultrawingrid 9.2

In my subclass of Ultrawingrid.Ultragrid :

Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)

    If e.KeyCode = Windows.Forms.Keys.Tab andalso e.control = True then 
        SetFocusToNextControl(True)
    End if

   Mybase.OnKeyDown(e)

End Sub

This works fine. But when the grid is dropped on a TabControl tabpage, the ctrl-tab looks very different to the sub above. e.keycode is seen as controlkey {17}

I realize that by default cntrl-Tab moves between tabpages. I need to override this behavior. My thought is I probably need a subclass of the tabControl which will pass the keycombo through just as the form does but I confess to being clueless as to how to accomplish that. I tried to override the onkeydown of a tabcontrol subclass and just issuing a return and not and base call to onkeydown if the ctrl-tab combo was pressed but it seemed to see the e.keycode as controlkey as well.

FWIW I tried a different combination like ctrl-E and got pretty much the same result with focus disappearing from the grid but not going anywhere I could detect. The sub still saw the e.control as controlkey.

Oddly, ctrl-X, ctrl-A etc all work in the grid and a ctrl-Delete combo I put in the subclass for deleting a row works fine.

Once again - grid directly on form and it all works.

I'm definitely over my head on this one. Guidance much appreciated. vb or c# fine.

TIA

© Stack Overflow or respective owner

Related posts about c#

Related posts about vb.net