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?
BTW,I also tried moving this code to the MouseUp event.
The logic is called and executed, but again, nothing happens.
Hi Richard,
How did you assign your ContextMenu to the grid? Are you using the inbox ContextMenu or ContextMenuStrip? Or are you using UltraToolbarsManager?