Context Menu Not Closing

F

Fred

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
 
N

NickP

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.
 
F

Fred

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_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles lstStaff.MouseUp
If e.Button = MouseButtons.Right Then

lstStaff.ContextMenu = Me.mnuPopup
lstStaff.ContextMenu.Show(lstStaff, New Point(e.X,
e.Y))
lstStaff.ContextMenu = Nothing
End If
End Sub



Fred
 
F

Fred

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.Show 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top