2

I need to set shortcut Ctrl + "Plus Sign" for one of the MenuStrip menu item.

I prefer to set it NOT programmatically to have an help text block in the right side of menu item:

Screenshot of menu

But I do not see there such variant to choose. Closest is "OemPlus"

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
Andrew_STOP_RU_WAR_IN_UA
  • 9,318
  • 5
  • 65
  • 101
  • I cant remember the name of it, but I'm sure you can find it.. there's a property on the menu item that allows you to override the hotkey text with whatever text you like. – Sam Axe Mar 09 '17 at 21:03

2 Answers2

2

Oemplus is the right setting. If you don't like the text, change ShortcutKeyDisplayString as well, e.g. to Ctrl++

Screenshot of Hotkey

Note that it is called OemPlus and not NumPlus, so does not work for the Numpad plus. Some people don't seem to know where the plus sign is and will try the Numpad plus.

If you need both, you need KeyPreview = true and code:

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
    if (keyData == (Keys.Control | Keys.Add))
    {
        MessageBox.Show("Ctrl+Numplus");
        return true;
    }
    if (keyData == (Keys.Control | Keys.Oemplus))
    {
        MessageBox.Show("Ctrl+Oemplus");
        return true;
    }
    return base.ProcessCmdKey(ref msg, keyData);
}
Thomas Weller
  • 55,411
  • 20
  • 125
  • 222
0

The answer can be found in MSDN https://msdn.microsoft.com/en-us/library/ms171651(v=vs.110).aspx

To display custom shortcut keys for a menu command

Set the menu command's ShortcutKeyDisplayString property to the desired keyboard combination, such as CTRL+SHIFT+S and set the ShowShortcutKeys property to true.

Dave S
  • 973
  • 9
  • 17