Mnemonic not showing on a System.Windows.Forms.ContextMenu
Asked Answered
P

2

0

I'm having some problems with Mnemonics and ContextMenus - although the Mnemonic property of the Menutem is set correctly the little underline wont show under the relevant key. Here is my code:

private void Form1_MouseDown(object sender, MouseEventArgs e)
{
    System.Windows.Forms.ContextMenu menu = new ContextMenu();
    menu.MenuItems.Add("Hello &World");
    menu.Show(this, e.Location);
}

What am I doing wrong?

Plebiscite answered 5/10, 2009 at 13:37 Comment(0)
B
7

There is a windows setting to "Hide underlined letters for keyboard navigation until I press the ALT key." It is under Display Properties --> Appearance --> Effects on XP ... Could that be what you're seeing?

Beforetime answered 5/10, 2009 at 14:12 Comment(2)
Aahhhh - now you mention it its so obvious!Plebiscite
This was my solution! Except we are many years ahead in Windows 10... Here's how to find it: Control Panel -> Ease of Access -> Change how your keyboard works -> Underline keyboard shortcuts and access keys.Introgression
A
0

Your code should work. Try using different text for your menu item. e.g "&Hello" or "&World". Also try setting the ShowShortcut to true, though .NET should do it for you by default.

menu.MenuItems[0].ShowShortcut = true;
Aperient answered 5/10, 2009 at 14:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.