Is there a way to force always show mnemonics in menus?

≯℡__Kan透↙ 提交于 2019-12-03 22:30:39

问题


I am making use of ContextMenuStrip in my program and apparently, it wont show its shortcut keys (mnemonics, those that should be shown as underlines under letters preceded by &) unless i press Alt, but when i press Alt, the shown ContextMenuStrip will hide because the main menu of the form will receive focus. Thus, in context menus, mnemonics are never seen!

Is there a way to force this behavior to be on for my program? I've read elsewhere that you can change it somewhere in the system settings, but i need people using my software to always see mnemonics, not require them globally changing their systems for my program to work correctly!

I have to show this menu via code in the KeyDown event handler when user presses Enter because its a popup for quick edit of a value represented by control. User clicks the control and can quickly change its contents. Think of it like in C# when you have a popup that pops on ctrl+space hinting possible code snipplets you can insert in this exact spot. So using it as a "context menu" property of a control or using keyboard "show context menu" button doesnt apply.

Thanks!


回答1:


That is an operating system setting:

Control Panel\All Control Panel Items\Ease of Access Center\Make the keyboard easier to use\Make it easier to use keyboard shortcuts\Underline keyboard shortcuts and access keys.




回答2:


Change the way the context menu is invoked. Don't show it manually, instead use something like:

textBoxSomething.ContextMenuStrip = yourContextMenuStrip;

In this case, if the user right-click on the text box (or other control you use), he will get the menu without mnemonics. But if he uses the keyboard context-menu-button to show the context menu, the mnemonics will be shown.



来源:https://stackoverflow.com/questions/10163617/is-there-a-way-to-force-always-show-mnemonics-in-menus

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