I have a Windows Form shown as a model dialog. It has a context menu of class ContextMenuStrip. I set shortcuts to several items in the context menu. But this shortcuts works only when context menu is shown. How to make them work even if the context menu is not activated?
The only way I know is to handle KeyPress event of the form, iterate recursively through all the items in the context menu and compare its ShortcutKeys property with the actual key pressed. If the match, manually call OnClick event for this item. Any better ideas?
Finally, I’ve implemented manual iteration in the
KeyPressedevent handler: