Context Menu Not Closing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fred

    Context Menu Not Closing

    Hi,

    I have a list box with a context menu. When I right click the menu
    appears as expected. However when I select an option on the context
    menu the menu does not close. The click event on the menu is fired but
    the menu remains.

    Is there anyway I can get this menu to close when I select a menu
    option?

    Ive tried setting the ContextMenu property of the list box to nothing
    but the menu remains :(

    Its not until I click elsewhere that the menu disappears.

    Thanks for any help

    Fred

  • NickP

    #2
    Re: Context Menu Not Closing

    Hi there,

    Can you should the code you are using to make the context menu appear
    please....

    If it's in an event could you copy and paste the entire event please,
    that would be helpful.

    Nick.

    "Fred" <fred@fredthoma s.co.ukwrote in message
    news:1165239835 .449872.316880@ 80g2000cwy.goog legroups.com...
    Hi,
    >
    I have a list box with a context menu. When I right click the menu
    appears as expected. However when I select an option on the context
    menu the menu does not close. The click event on the menu is fired but
    the menu remains.
    >
    Is there anyway I can get this menu to close when I select a menu
    option?
    >
    Ive tried setting the ContextMenu property of the list box to nothing
    but the menu remains :(
    >
    Its not until I click elsewhere that the menu disappears.
    >
    Thanks for any help
    >
    Fred
    >

    Comment

    • Fred

      #3
      Re: Context Menu Not Closing

      Just in case anyone else gets this problem ......

      I changed the code and it all works fine now.

      Instead of setting the Context menu at Design time I do it all at
      runtime.....


      Private Sub lstStaff_MouseU p(ByVal sender As Object, ByVal e As
      System.Windows. Forms.MouseEven tArgs) Handles lstStaff.MouseU p
      If e.Button = MouseButtons.Ri ght Then

      lstStaff.Contex tMenu = Me.mnuPopup
      lstStaff.Contex tMenu.Show(lstS taff, New Point(e.X,
      e.Y))
      lstStaff.Contex tMenu = Nothing
      End If
      End Sub



      Fred


      Fred wrote:
      Hi,
      >
      I have a list box with a context menu. When I right click the menu
      appears as expected. However when I select an option on the context
      menu the menu does not close. The click event on the menu is fired but
      the menu remains.
      >
      Is there anyway I can get this menu to close when I select a menu
      option?
      >
      Ive tried setting the ContextMenu property of the list box to nothing
      but the menu remains :(
      >
      Its not until I click elsewhere that the menu disappears.
      >
      Thanks for any help
      >
      Fred

      Comment

      • NickP

        #4
        Re: Context Menu Not Closing

        Thanks for posting an update, good to hear you got it sorted.

        Nick.

        "Fred" <fred@fredthoma s.co.ukwrote in message
        news:1165246915 .955688.244340@ 73g2000cwn.goog legroups.com...
        Just in case anyone else gets this problem ......
        >
        I changed the code and it all works fine now.
        >
        Instead of setting the Context menu at Design time I do it all at
        runtime.....
        >
        >
        Private Sub lstStaff_MouseU p(ByVal sender As Object, ByVal e As
        System.Windows. Forms.MouseEven tArgs) Handles lstStaff.MouseU p
        If e.Button = MouseButtons.Ri ght Then
        >
        lstStaff.Contex tMenu = Me.mnuPopup
        lstStaff.Contex tMenu.Show(lstS taff, New Point(e.X,
        e.Y))
        lstStaff.Contex tMenu = Nothing
        End If
        End Sub
        >
        >
        >
        Fred
        >
        >
        Fred wrote:
        >Hi,
        >>
        >I have a list box with a context menu. When I right click the menu
        >appears as expected. However when I select an option on the context
        >menu the menu does not close. The click event on the menu is fired but
        >the menu remains.
        >>
        >Is there anyway I can get this menu to close when I select a menu
        >option?
        >>
        >Ive tried setting the ContextMenu property of the list box to nothing
        >but the menu remains :(
        >>
        >Its not until I click elsewhere that the menu disappears.
        >>
        >Thanks for any help
        >>
        >Fred
        >

        Comment

        • Fred

          #5
          Re: Context Menu Not Closing

          Nothing more frustrating than seeing someone else post the same problem
          you've got but no follow up posts to say how it was solved! ;)

          I discovered that setting a context menu at design time brought about a
          few problems.

          1. The menu did not disappear on click of a menu option.
          2. Although I had the ContextMenu.Sho w in the MouseUp event it was
          showing on the mouse down :s
          3. I put a trap on the ListView selected Items property to say "don't
          show the menu if nothing is selected" which it totally ignored!

          All seemed strange to me but im sure there is some logic in there
          somewhere!!

          Thanks for responding though Nick.

          Fred

          NickP wrote:
          Thanks for posting an update, good to hear you got it sorted.
          >
          Nick.
          >
          "Fred" <fred@fredthoma s.co.ukwrote in message
          news:1165246915 .955688.244340@ 73g2000cwn.goog legroups.com...
          Just in case anyone else gets this problem ......

          I changed the code and it all works fine now.

          Instead of setting the Context menu at Design time I do it all at
          runtime.....


          Private Sub lstStaff_MouseU p(ByVal sender As Object, ByVal e As
          System.Windows. Forms.MouseEven tArgs) Handles lstStaff.MouseU p
          If e.Button = MouseButtons.Ri ght Then

          lstStaff.Contex tMenu = Me.mnuPopup
          lstStaff.Contex tMenu.Show(lstS taff, New Point(e.X,
          e.Y))
          lstStaff.Contex tMenu = Nothing
          End If
          End Sub



          Fred


          Fred wrote:
          Hi,
          >
          I have a list box with a context menu. When I right click the menu
          appears as expected. However when I select an option on the context
          menu the menu does not close. The click event on the menu is fired but
          the menu remains.
          >
          Is there anyway I can get this menu to close when I select a menu
          option?
          >
          Ive tried setting the ContextMenu property of the list box to nothing
          but the menu remains :(
          >
          Its not until I click elsewhere that the menu disappears.
          >
          Thanks for any help
          >
          Fred

          Comment

          Working...