Hey,
Anyone know a way to cancel a Context Menu popup in the popup event?
Thanks,
Ben
Printable View
Hey,
Anyone know a way to cancel a Context Menu popup in the popup event?
Thanks,
Ben
Not sure exactly what you mean, or why you'd want to do this at that point, but......will prevent any context menu from being displayed at the point of the popup event.VB Code:
Dim m As MenuItem For Each m In ContextMenu.MenuItems m.Visible = False Next
I want to (sometimes) suppress the context menu when the user right-clicks my control.. but only sometimes. Specifically when they click inside my listview control, but not on an actual list item.
--Ben
Im not at a .net machine atm. but check the passed arguments in the popup event. Should be e. something if you can do it. Else it could be that you have to add an event handler for click and then showing it yourself.
In that case, modify the above code to...Quote:
Originally posted by BenFinkel
Specifically when they click inside my listview control, but not on an actual list item.
This will then only display the popup menu when actually clicking on an item - anywhere else nothing will popup.VB Code:
Dim m As MenuItem For Each m In ContextMenu1.MenuItems m.Visible = CBool(ListView1.SelectedItems.Count) Next
That what your after?