Search code examples
.netwinformskeyboard-shortcuts

ALT+ENTER Keyboard Shortcut to open Properties


I am writing a winforms application and one of the functions is to open an item's properties. I'm not able to find out how to handle this. A menu item doesn't allow to define such a keyboard shortcut and implementing the handler manually with the keyup or keypress event handlers doesn't work either. Anyone out there who knows how to do this?


Solution

  • I think Thomas is correct, you must use a ToolStripMenuItem. Adding the following line to my .designer file worked like a champ:

    this.fileProperties.ShortcutKeys = System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.Enter;
    

    The keystroke works and the string Alt + Enter is displayed on the menu item.