Context Menu Auto Close doesnt work

  • 13 years ago

     Hi all i was wondering wheather anyone knows about the context menu autoclose feature because it doesnt seem to work for me.

    I have a context menu associated with a control and i have auto close set to false but now my context menu wont show i have tried all sorts


    contextmenu mouse events but nothing seems to be working hmmm.

    What im trying to achieve is right click a control activate the context menu make several selections and then close the menu by using the mouse leave event handler.

    any help would be great

    Many Thanks


  • 13 years ago

      Private Sub ContextMenuStrip1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles ContextMenuStrip1.MouseLeave
        ContextMenuStrip1.AutoClose = True
      End Sub

      Private Sub ContextMenuStrip1_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStrip1.Opening
        ContextMenuStrip1.AutoClose = False
      End Sub

    Just be sure to set the control's ContextMenu to ContextMenuStrip1 or you have to handle opening it too. Let the OS handle the popup part. The ContextMenuStrip1.AutoClose should be set to True at design time (default). 

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC. As potential programmers, they are mentally mutilated beyond hope of regeneration.” - E. W. Dijkstra