Keyboard Shortcuts in Windows Forms xp toolbar (XPToolbar)

29 Apr 20211 minute to read

The bar items can be selected through keyboard operation by specifying the shortcuts via the Shortcut property of each item.

NOTE

  1. By using this keyboard shortcuts, we can access the bar items functionality through Click event.
  2. In this illustration, we have used BarItem. Similarly, we have set the shortcuts for ParentBarItem, DropDownBarItem, ComboBoxBarItem, ListBarItem, StaticBarItem, ToolbarListBarItem and TextBoxBarItem.

The below code snippet shows how shortcut is assigned to the bar item.

this.barItem1.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
Me.barItem1.Shortcut = System.Windows.Forms.Shortcut.CtrlN

Keyboard Shortcuts

User can also specify custom text in place of keyboard shortcuts region using the ShortcutText property.

this.barItem1.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
this.barItem1.ShortcutText = "Press Ctrl + N";
Me.barItem1.Shortcut = System.Windows.Forms.Shortcut.CtrlN
Me.barItem1.ShortcutText = "Press Ctrl + N"

Keyboard Shortcuts