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 + S and the menu item's handler is "magically" executed after pressing Ctrl + S.
问题在于数字键盘上的按键,ShortcutKey
属性不接受它们(我不明白它们与其他可接受的键有何不同)。
MSDN 声明该属性接受类型系统.Windows.Forms.键(Keys 值之一。默认为 None。);和InvalidEnumArgumentException
当参数不是其中之一时会抛出Keys价值观。但例如 Keys.DivideISKeys 值之一,但无法使用。
那么如何设置菜单项具有数字键盘的快捷方式*
或数字键盘+
?我需要处理表单中的密钥吗进程命令键 event?
You must use Ctrl or Alt in shortcuts.
例子:
//working:
toolStripMenuItem1.ShortcutKeys = Keys.Control | Keys.NumPad0;
//throws exception
toolStripMenuItem1.ShortcutKeys = Keys.NumPad0;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)