Skip to main content
Bar

BarItem.ItemShortcut Property

Gets or sets the shortcut used to access the associated links with the keyboard.

Namespace: DevExpress.XtraBars

Assembly: DevExpress.XtraBars.v23.2.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

[DXCategory("Behavior")]
public virtual BarShortcut ItemShortcut { get; set; }

Property Value

Type Description
BarShortcut

A BarShortcut object specifying the key combination used to access links associated with this item.

Remarks

You can respond to link clicks by handling the BarItem.ItemClick or BarManager.ItemClick event. The same events are raised when you press the ItemShortcut key combination.

Bar items do not appear depressed when a user presses shortcuts. Shortcuts cannot be used to expand sub-menus.

At design time, use the combo box available for the ItemShortcut property in the Visual Studio Property Grid to select one of the predefined shortcuts. Choose (custom) to invoke the custom shortcut editor.

BarItem.ItemShortcut

You can specify up to two combinations. For instance, you can specify the “CTRL+J, CTRL+K” shortcut for an item. You need to sequentially press both shortcuts to execute the command. Note, you cannot use the first combination (“CTRL+J”) for another bar item.

The following example shows how to specify a custom shortcut:

barButtonItem1.ItemShortcut = new DevExpress.XtraBars.BarShortcut((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.M));
barButtonItem2.ItemShortcut = new DevExpress.XtraBars.BarShortcut((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.J), (System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.K));

The text representation of item shortcuts is displayed for items when they are embedded in a popup menu or sub-menu, and the menu’s MenuDrawMode property is set to SmallImagesText.

To provide a custom display string for the assigned shortcut, use the BarItem.ShortcutKeyDisplayString property.

Note

Do not assign system shortcuts to bar items. For instance, the Ctrl+A shortcut is used to select text in a text box. The Ctrl+C shortcut is used to copy the selected text. The Esc shortcut is used to close dropdown windows. Do not assign these shortcuts and such to bar items. Otherwise, conflicts and unpredictable results may occur. Handle the ShortcutItemClick event to process system shortcuts.

See Also