Ticket T932660
Visible to All Users

How to show a command shortcut in SpreadsheetControl's context menu

created 4 years ago

Hi, Devexpress Supporters.

How to modify shortcut string like as Excel popup menu on Spreadsheet?

Answers approved by DevExpress Support

created 4 years ago

Hello,
If I correctly understand it, you want to show the command shortcut in the Spreadsheet context menu. To do this, you can handle the SpreadsheetControl.PopupMenuShowing event, find the required menu item, and modify an item caption using the SpreadsheetMenuItem.Caption property.
Please review the following code snippet, which demonstrates how to show the "CTRL+C" shortcut for the "Copy" context menu item.

C#
private void SpreadsheetControl_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) { foreach (var item in e.Menu.Items) if (item is SpreadsheetMenuItem && (item as SpreadsheetMenuItem).Id == SpreadsheetCommandId.CopySelection) (item as SpreadsheetMenuItem).Caption += " (CTRL+C)"; }

See also:
How to: Customize or Hide the Popup Menu
Keyboard Shortcuts

    Comments (2)
    S S
    Sungmin Steve Jung 4 years ago

      If so, can I change the caption in the designer?

      You can look attached image.
      I think that can change it in the following order.

      1. Run Designer.
      2. Sub Menus & Popup Menus Click
      3. Menu Object Select
      4. Menu Select
      5. Change Caption
      Maria Nikulina (DevExpress) 4 years ago

        Context menu items and their captions are dynamically generated before the context menu is opened. Thus, captions cannot be changed at design time. I can only recommend you use the PopupMenuShowing event to customize these captions.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.