Search code examples
c#winformseditordevexpressxtragrid

Is there a way to disable copy paste for editor column in devexpress xtraGrid?


I have a devexpress xtraGrid. One column is editable. When I select the text in this column and right click, a menu will pop up. There are "Undo, Cut, Copy, Paste, Delete and Select All" in this menu.

Looks like if I use for example "cut" button to cut all text in the cell, the gridviewcellvaluechaning event is not fired. And we have our own customized right click popup menu as well. I want to disable the xtragrid default one, but I search for a while didn't find useful information. Any guidance is really appreciated!

Thanks!


Solution

  • From http://www.devexpress.com/Support/Center/p/CQ31618.aspx

        ContextMenu emptyMenu = new ContextMenu();
            this.components.Add(emptyMenu);
    
        private void gridView1_ShownEditor(object sender, System.EventArgs e) {
            DevExpress.XtraGrid.Views.Grid.GridView view = 
                               sender as DevExpress.XtraGrid.Views.Grid.GridView;
            if(!view.IsFilterRow(view.FocusedRowHandle)) return;
            view.ActiveEditor.ContextMenu = emptyMenu;
        }