Thanks for the tip. This is what I ended up with.
-Justin
private void qgView_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { Point mousePoint = new Point(e.X, e.Y); UIElement element = ((UltraGrid)sender).DisplayLayout.UIElement.ElementFromPoint(mousePoint); UltraGridCell cell = element.GetContext(typeof(UltraGridCell)) as UltraGridCell; if (cell != null) { ((UltraGrid)sender).ContextMenuStrip = this.queryGridContextMenuStrip1; } else { ((UltraGrid)sender).ContextMenuStrip = null; } } }
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