How to disable menu shortcut keys

A

Amil Hanish

I have shortcut keys to my menu in VS 2008 windows forms. I disable the
menu item when the menu is clicked; that works fine. But the user can still
press the shortcut key.

What is the PREFERRED way to handle shortcut keys and when pressed, check
them to verify they are valid. I was thinking of the KeyDown event in the
form.

amil
 
H

Herfried K. Wagner [MVP]

Amil Hanish said:
I have shortcut keys to my menu in VS 2008 windows forms. I disable the
menu item when the menu is clicked; that works fine. But the user can
still press the shortcut key.

What is the PREFERRED way to handle shortcut keys and when pressed, check
them to verify they are valid. I was thinking of the KeyDown event in the
form.

Handle the menu item's 'Click' event. Inside the 'Click' event handler you
can check if the menu item is enabled (the 'sender' parameter contains a
reference to the menu item the event belongs to).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top