Any way to stop menu strip from 'capturing' alt-key?
-
Hi All, I have a Win Form on which I use the KeyDown event to perform certain activities using Alt-Key combinations. Unfortunately, this also triggers the menustrip 'capturing' the Alt key and highlighting the default menu item ('File') and essentially disabling any further typing until the Alt key is pressed again. Is there any way to stop the file menu from capturing the Alt when this is used to trigger operations in the KeyDown event? Thanks, Sri
-
Hi All, I have a Win Form on which I use the KeyDown event to perform certain activities using Alt-Key combinations. Unfortunately, this also triggers the menustrip 'capturing' the Alt key and highlighting the default menu item ('File') and essentially disabling any further typing until the Alt key is pressed again. Is there any way to stop the file menu from capturing the Alt when this is used to trigger operations in the KeyDown event? Thanks, Sri
-
How are you checking if Alt key was pressed? Instead of
e.KeyCode == Keys.Alt
, use e.Alt.It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
Hi, Thanks for your reply.Unfortunately, i did not write single piece of code to check which key was pressed. In form i have added button text like (&Help...etc). my menustrip still captures the alt key(First time), and still disables any further typing until I press alt again. I'm using key combinations of Alt-A, Alt-D etc to focus onto various fields on the form. Any of these will force the menustrip to capture the Alt key. Regards, Sri
-
Hi, Thanks for your reply.Unfortunately, i did not write single piece of code to check which key was pressed. In form i have added button text like (&Help...etc). my menustrip still captures the alt key(First time), and still disables any further typing until I press alt again. I'm using key combinations of Alt-A, Alt-D etc to focus onto various fields on the form. Any of these will force the menustrip to capture the Alt key. Regards, Sri
Your key-combinations (where Alt and A are both pressed at the same time) work, even if a single keypress on the Alt prevents further input. A keypress on Alt should give you the option to browse the menu. Windows doesn't capture the key, but the focus. The second keystroke then determines what menu to open. That's two seperate keystrokes. Your key-combination is Alt-A, and the A is typed while the Alt-key is down. That gives different behaviour on Windows - it first checks if there's a shortcut-key defined (e.g., the letter right after the "&"-char in the caption of a button) These two behaviors shouldn't bite each other. If your end-user is like me, he'll be using the Alt-key often enough to navigate the menu :)
I are Troll :)