Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Putting hotkey/shortcut text next to toolstrip menu items in winforms

I want to be able to show the hotkey combination assigned to a toolstrip menu item in winforms. For instane, in any program (even your browser settings menu) you can see various menu items, and generally, aligned to the right of their item, is their hotkey shortcut. I want to do this programmatically.

Example: Instead of typing

Open a file                         (ctrl+O)

I want to have the properties show up independently of each other.

How can I achieve this?

like image 256
jwarner112 Avatar asked Oct 11 '13 15:10

jwarner112


People also ask

How can you add shortcut key to a menu item in VB?

Set Shortcut Keys for Menu ItemsSelect the Edit menu item and select its ShortcutKeys property in the properties window. Click the drop down button next to it. Select Ctrl as Modifier and E as the key.


1 Answers

You want to you use the ShortcutKeys property of the ToolStripMenuItem. This will let you pick the particular key combination you want for each menu item and it will show up to the right of the menu item. Make sure that you have ShowShortcutKeys property of the ToolStripMenuItem set to true.

like image 51
Scott Wylie Avatar answered Sep 28 '22 11:09

Scott Wylie