Hello
When the mouse is positioned over an area other than a winGridRow (Header for example) I do not want to display the windows.forms.contextmenu assigned to the grid. In other words, I'd like to be able to cancel the displaying of the context menu. I've implemented the following code which doesn't work:
Private Sub grd_MouseEnterElement(ByVal sender As Object, ByVal e As Infragistics.Win.UIElementEventArgs) Handles ug1.MouseEnterElement If TypeOf e.Element Is Infragistics.Win.UltraWinGrid.HeaderUIElement Or TypeOf e.Element Is Infragistics.Win.UltraWinScrollBar.ScrollBarUIElement Then popcontextmenu = False Else popcontextmenu = True End If End Sub
Then in my contextmenu popup event, the first test that I do is to see if I can display the menu based on the value of popcontextmenu. It's always displaying.
How can I accomplish this?
Thank you
Clay Seifert
Thank you Brian. Worked like a charm.
Private Sub ug1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles ug1.MouseDown
If e.Button = Windows.Forms.MouseButtons.Right Then
Dim mousePoint As Point = New Point(e.X, e.Y) Dim hitTest As UIElement = ug1.DisplayLayout.UIElement.ElementFromPoint(mousePoint)
If TypeOf hitTest Is Infragistics.Win.EditorWithTextDisplayTextUIElement Then ug1.ContextMenu = cmuTestEquipInfo Else ug1.ContextMenu = cmuEmptyMenu End If
hitTest = Nothing
End If
End Sub
I would handle MouseDown, hit test for the element(s) for which you want to exclude the context menu, and set the ContextMenu property to either null or the ContextMenu instance that has the menu items depending on whether you want to show the menu.