By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,213 Members | 1,401 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,213 IT Pros & Developers. It's quick & easy.

Context Menu Not Closing

P: n/a
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

Dec 4 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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" <fr**@fredthomas.co.ukwrote in message
news:11**********************@80g2000cwy.googlegro ups.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

Dec 4 '06 #2

P: n/a
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
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
Dec 4 '06 #3

P: n/a
Thanks for posting an update, good to hear you got it sorted.

Nick.

"Fred" <fr**@fredthomas.co.ukwrote in message
news:11**********************@73g2000cwn.googlegro ups.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_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
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

Dec 4 '06 #4

P: n/a
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

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

Nick.

"Fred" <fr**@fredthomas.co.ukwrote in message
news:11**********************@73g2000cwn.googlegro ups.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_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
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
Dec 4 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.