How to make popup menu with right click on GridControl row?

Dominating picture Dominating · Mar 8, 2011 · Viewed 21.9k times · Source

I have a GridControl with some rows on my DevExpress interface. When I right-click on some row of the grid I want to pop-up the same kind of menu like when i right-click on my desktop(win 7), but only with 3 options - Cut, Paste and Copy.

How to make this? Is there a way to say in the property editor of the GridControl "for every row if right-click then popup a Menu". If so, is this menu stored in a repository and what type is this menu?

Answer

Jhollman picture Jhollman · Feb 1, 2016
  1. Add a DevXpress.ExtraBars.BarManager Control.
  2. Add a DevXpress.ExtraBars.PopupMenu Control.
  3. Create your menu structure inside the PopupMenu control.
  4. Add this code into the 'PopupMenuShowing' event of your GridView:

    private void gridView1_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e) 
    {
        if (e.HitInfo.InRow) 
        {
            System.Drawing.Point p2 = Control.MousePosition;
            this.popupMenu1.ShowPopup(p2);
        }
    }
    

That's It!