Skip to main content
A newer version of this page is available. .

How to: Prevent Specific Shortcuts from Being Processed by the BarManager

Let us assume, that a form contains the following components:

  • list box
  • Bar Manager with a bar containing the Del bar item which is intended to delete the focused element from the list box. Its shortcut is set to the DELETE key.
  • a text box. Pressing the DELETE key while editing in the text box should clear the selected text

By default, when any control is focused, pressing the DELETE key will always invoke the bar item’s functionality. To prevent this when the text box is focused, we need to handle the BarManager.ShortcutItemClick event.

private void barManager1_ShortcutItemClick(object sender, 
  DevExpress.XtraBars.ShortcutItemClickEventArgs e) {
    if(e.Shortcut.Key == Keys.Delete)
        e.Cancel = textBox1.Focused;
}