Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
570
Suppress Context Menu Except on Selected Rows?
posted
I have a grid with multiple bands.  I only want my context menu to show if there is a selected row, and if the user right clicks on that row.  Currently, the context menu will show if the user right clicks on row or column headers, the group by box, group by rows, regular rows, or the grid background.  How can I suppress the menu except for the cases I wish to show it?
Parents
No Data
Reply
  • 469350
    Offline posted

    Hi,

    Well... if you are assigning the ContextMenu or ContextMenuStrip property on the grid, then what you would have to do is assign it dynamically. In other words, don't set it at design-time, set it in the MouseMove event of the grid. In this event, you can determine what part of the grid the mouse is over and assign a ContextMenu to the grid or not depending on where the mouse is.

    To determine what part of the grid the mouse is over, you use the ElementFromPoint method. There are lots of KB articles in the Infragistics Knowledge Base with samples demonstrating how to do this. The one most applicable here is this one: 

     HOWTO:UltraWinGrid Mouse Position and Row Identification

     

Children