Search code examples
vb.netkeyboard-shortcutsmenustrip

Disable Alt + key shortcut keys in menu strip in vb.net


I am using MenuStrip in my project in vb.net. I have created two main menus: one is Master and the other is Help. Now anyone press ALT   +M then it will open master menu and if press ALT   +H then it will open Help menu.

Now I want to prevent this functionality and restrict user to press ALT   +[ A KEY ] to open menu.

Can anyone give me an idea to do this?


Solution

  • Set your form's KeyPreview property to True and test for the key combinations you want to prevent in its KeyDown event, then set e.SuppressKeyPress = True.

    However, I would generally recommend against doing this. People expect to be able to access menus using keyboard shortcuts in Windows applications. Denying them that option makes an application (a) non-compliant with Windows standards, and (b) less user friendly.