New to Telerik UI for WinForms? Download free 30-day trial

Getting Started with WinForms Shortcuts (RadMenuItems)

1. In a new Windows Application add a RadMenu to the form.

2. On the RadMenu that reads "Type here" enter "New". This will automatically create a menu item object "radMenuItem1":

WinForms RadShortcuts Design Time

3. Click and the newly created item to open the drop down menu and create a sub menu item. By default, the text of the new item will be set to radMenuItem2. Change it to File:

WinForms RadShortcuts Created MenuItem Design Time

4. In the Properties Window locate the Click events for radMenuItem1 and radMenuItem2 and double-click them to create event handlers.

5. Inside the event handlers add the following code:

void radMenuItem1_Click(object sender, EventArgs e)
void radMenuItem2_Click(object sender, EventArgs e)

Private Sub radMenuItem1_Click(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Private Sub radMenuItem2_Click(ByVal sender As Object, ByVal e As EventArgs)
End Sub

6. Now, all you have to do is to add the shortcuts to the desired items

this.radMenuItem1.Shortcuts.Add(new RadShortcut(Keys.Control, Keys.N));
this.radMenuItem2.Shortcuts.Add(new RadShortcut(Keys.Shift, Keys.F, Keys.K));

Me.RadMenuItem1.Shortcuts.Add(New RadShortcut(Keys.Control, Keys.N))
Me.RadMenuItem2.Shortcuts.Add(New RadShortcut(Keys.Shift, Keys.F, Keys.K))

In the constructor of RadShortcut, you should first pass the key modifier as a parameter and then an array of the key mappings.

As a result, you will get this picture at run time. As you can see, the shortcuts are automatically displayed for the RadMenuItems:

WinForms RadShortcuts Add Shortcut

Interesting functionality to mention is the ability to set your own custom text to describe the shortcut added. This can be achieved via the HintText property of the menu item:

Specifying HintText

radMenuItem2.HintText = "Custom Text";

RadMenuItem2.HintText = "Custom Text"

WinForms RadShortcuts Specifying HintText

See Also

Telerik UI for WinForms Learning Resources

In this article