Setting the Windows Forms ToolStripMenuItem ShortcutKeys property to numpad key does not work

后端 未结 2 1673
后悔当初
后悔当初 2021-01-13 16:56

We have the ability to define shortcut keys for Windows Forms application menu items. That way I can tell a menu item File->Save to have the shortcut key Ctrl<

相关标签:
2条回答
  • 2021-01-13 17:24

    You must use Ctrl or Alt in shortcuts.

    example:

    //working:  
    toolStripMenuItem1.ShortcutKeys = Keys.Control | Keys.NumPad0;  
    //throws exception  
    toolStripMenuItem1.ShortcutKeys = Keys.NumPad0;  
    
    0 讨论(0)
  • 2021-01-13 17:29

    To answer the question about using Numpad * and Numpad +:

    • Numpad * is called the multiply key. The enumeration name is Multiply.

    • Numpad + is called the add key. The enumeration name is Add.

    • Numpad - is called the subtract key. The enumeration name is Subtract.

    It is not possible to select these in Visual Studio's property window (at least not in Visual Studio 2008), but the corresponding source code can be edited; where property ShortcutKeys is set. For example for Numpad + for a menu item named mnuMoreTime:

    this.mnuMoreTime.ShortcutKeys = 
        ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control |
                                      System.Windows.Forms.Keys.Add)));
    
    0 讨论(0)
提交回复
热议问题