KB Article A597
Visible to All Users

How to force a grid to show my own context menu instead of the standard one when right-clicking an in-place editor

Description:
I do not wish my users to see the standard <Copy - Paste> menu. How can I replace it with my own?

Answer:
This feature can be implemented using the ShownEditor event of the GridView object. All you need to do is to access the GridView's ActiveEditor property and set its ContextMenu property value to your own ContextMenu:

C#
private void gridView1_ShownEditor(object sender, System.EventArgs e) { DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView; contextMenu1.MenuItems.Add(contextMenu1.MenuItems.Count, new MenuItem("SomeText")); view.ActiveEditor.ContextMenu = contextMenu1; }

We also recommend that you refer to the following KB article where we described the concept of Popup Menus in greater detail:
DevExpress WinForms Cheat Sheets - Context Menus

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.