Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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;
}