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

大城市里の小女人 提交于 2019-12-01 08:33:26
Avram

You must use Ctrl or Alt in shortcuts.

example:

//working:  
toolStripMenuItem1.ShortcutKeys = Keys.Control | Keys.NumPad0;  
//throws exception  
toolStripMenuItem1.ShortcutKeys = Keys.NumPad0;  

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)));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!