Getting the Left and Right arrow keys to select the previous/next menu instead of the next/previous menu

荒凉一梦 提交于 2019-12-06 00:52:39

This is a bug/misfeature in MenuStrip.

Looking at the ToolStripDropDown.ProcessArrowKey implementation with Reflector shows that the arrow keys get reversed depending on SystemInformation.RightAlignedMenus. That's not right. It should depend on the right-to-left mode of the menu strip itself, which may sometimes (usually?) match SystemInformation.RightAlignedMenus, but not always, and not on my system.

SystemInformation.RightAlignedMenus is user-configurable via Control Panel, Tablet PC Settings, Other, Handedness, and indeed if I change that to Left-handed, I get the menus to behave correctly. The default and correct setting for me is Right-handed. Since the MenuStrip component is simply not keyboard-usable on my system, I will replace my use of it with a standard MainMenu component.

Update: I'm actually using a derived control to be able to provide nice menu images. It is based on the Microsoft sample on "Visual Style Menus". A more fully-featured implementation that also works on Windows XP and prior (in that case using owner-drawn menus) is available at Vista Menu with Icons in C#, but that is more complicated than necessary for me.

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