.netgridviewmenudevexpressright-click

How to remove devexpress right-click menu from my gridview?


enter image description here

I dont want this menu. How to remove it? Which property should I use?


Solution

  • The menu from your picture actually is editor's context menu. The editor is created when you starting to edit the cell. Also this menu you can see only from TextEdit and its descendants. TextEdit itself is container which holds the System.Windows.Forms.TextBox descendant. By default, TextEdit prevents TextBox context menu and shows its own. But, if the value of TextEdit.ContextMenu or TextEdit.ContextMenuStrip properties are not null, then menu of this properties are showing instead of default menu. So, technically, if you create empty ContextMenu or ContextMenuStrip and update the properties by this menus, then the are no menu will be shown.

    You can use GridView.ActiveEditor property to get the current editor and you can use GridView.ShownEditor event to update the current editor context menu.
    Here is example:

    private void gridView1_ShownEditor(object sender, EventArgs e)
    {
        var view = (GridView)sender;
        var editor = view.ActiveEditor as TextEdit;
    
        if (editor == null)
            return;
    
        editor.ContextMenuStrip = new ContextMenuStrip();
    }