Ticket T198000
Visible to All Users

Show popup menu on grid

created 10 years ago

I created my own popup menu on the DevExpress grid control and now when I right-click on the grid, it always show my popup menu.
What I want is that

1 - When clicking on the grid header (or group area pane), it shows the default grid popup menus such as Sort Ascending, Sort Descending, Clear All sorting, etc.

2 - I want to show my popup only the in the grid area (beside the first row) but at the moment, it just shows everywhere.

I try the following codes and it just does not work well at all and before showing popup it blinks two or three times before showing

private void grdViewList_MouseDown(object sender, MouseEventArgs e)
         {
             if (e.Button == System.Windows.Forms.MouseButtons.Right)
             {
                 Point clickPoint = grdSelectDataset.PointToClient(Control.MousePosition);
                 var hitInfo = grdViewList.CalcHitInfo(clickPoint);
                 if (hitInfo.InRowCell)
                 {
                     pmDataViewer.ShowPopup(barManager1, new Point(e.X, e.Y));
                 }
             }
         }

Answers approved by DevExpress Support

created 10 years ago

Hello,

I suggest you create a GridViewMenu class instance and handle the GridView.PopupMenuShowing event to achieve your goal:

C#
void gridView1_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e) { if (e.HitInfo.HitTest == DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitTest.RowCell) e.Menu = menu; // menu is GridViewMenu instance }

I have attached a sample project.

Let me know if you need further assistance.

    Show previous comments (3)
    DevExpress Support Team 10 years ago

      Please take a look at the attached project. It illustrates that this code should work correctly and sub menu items can be displayed without any problem.

      Is this what you are looking for?

        I can´t seem to find the method PointToScreen for my gridcontrol.
        I wish o show a popupmenu when rightclicking in my gridview.

        Alisher (DevExpress Support) 9 years ago

          Hi Max,

          Being a control descendant, the GridControl component inherits this method. Would you please check whether you are looking for this method in the object of the GridView class? Also check the project attached by Dimitros to learn how this method is used.
          Please keep us posted.

          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.