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
1640
Fire context menu popup
posted

I need to programmatically show the context menu for a grid, but my logic isn't working.

I have defined a MouseDown event for the grid in order to disambiguate the click and double-click events if the left button is clicked.  If the right button is clicked I perform the following logic, but nothing happens:

if (sender is UltraGrid)
{
    UltraGrid grid = (UltraGrid)sender;
    if (grid.ContextMenu.SourceControl != null)
    {
        // X & Y values are from the MouseDown event
        Point point = new Point(e.X, e.Y);
        // The grid context control is a ContexMenuStrip control which worked correctly prior to the MouseDown implementation
        grid.ContextMenu.Show(grid.ContextMenu.SourceControl, point);
    }
}

What is wrong with the code?

Parents Reply Children
No Data