Results 1 to 5 of 5

Thread: Cancel ContextMenu popup...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    Buffalo, NY
    Posts
    297

    Cancel ContextMenu popup...

    Hey,

    Anyone know a way to cancel a Context Menu popup in the popup event?

    Thanks,

    Ben

  2. #2
    Member McBain2's Avatar
    Join Date
    Sep 2003
    Location
    UK, Glos.
    Posts
    60
    Not sure exactly what you mean, or why you'd want to do this at that point, but...
    VB Code:
    1. Dim m As MenuItem
    2.         For Each m In ContextMenu.MenuItems
    3.             m.Visible = False
    4.         Next
    ...will prevent any context menu from being displayed at the point of the popup event.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    Buffalo, NY
    Posts
    297
    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

  4. #4
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    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.

  5. #5
    Member McBain2's Avatar
    Join Date
    Sep 2003
    Location
    UK, Glos.
    Posts
    60
    Originally posted by BenFinkel
    Specifically when they click inside my listview control, but not on an actual list item.
    In that case, modify the above code to...
    VB Code:
    1. Dim m As MenuItem
    2.       For Each m In ContextMenu1.MenuItems
    3.          m.Visible = CBool(ListView1.SelectedItems.Count)
    4.       Next
    This will then only display the popup menu when actually clicking on an item - anywhere else nothing will popup.
    That what your after?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width