4

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?

JumpingJezza
  • 5,498
  • 11
  • 67
  • 106
Dominating
  • 2,890
  • 7
  • 25
  • 39

2 Answers2

3
  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!

JumpingJezza
  • 5,498
  • 11
  • 67
  • 106
Jhollman
  • 2,093
  • 24
  • 19
2

Handle the GridView's ShowGridMenu event to show the context menu when a gridRow is clicked. We have also published an example showing how this event can be used:

How to show a context menu for grid rows

DevExpress Team
  • 11,338
  • 2
  • 24
  • 23
  • The Method ShowGridMenu is marked as "Obsolete". They say: "You should use the '[PopupMenuShowing](http://documentation.devexpress.com/#windowsforms/DevExpressXtraSchedulerSchedulerControl_PopupMenuShowingtopic)' instead". – Chrigl Nov 27 '13 at 15:03