K
Karthik Vazhkudai
Hi All:
I have a contextmenu with each menu item comprising of a set of child
menus. This contextmenu is attached to an image control and is
displayed only when the user right-clicks on the image control. I am
having trouble in clearing out the contextmenu when the user
right-clicks and selects a menu option. What happens is that while the
contextmenu itself vanishes it leaves a small rectangular box on the
screen which only vanishes when I manually do an ALT-TAB into another
window and go back to my window with the contextmenu. The code I have
within the event handler of the menu option is as below:
'Somewhere, I attach an event handler to the menu
m.MenuItems.Add("&Event for Alarm ", New System.EventHandler(AddressOf
Me.JumpTo_OnClick))
..
..
..
'Event handler for the menu option
Protected Sub JumpTo_OnClick(ByVal sender As System.Object, ByVal e As
System.EventArgs)
...
For Each mnuItem As MenuItem In ContextMenu1.MenuItems
mnuItem.Enabled = False
mnuItem.Visible = False
mnuItem = Nothing
Next
ImageControl.ContextMenu = Nothing
ImageControl.Invalidate()
End Sub
Any suggestions as to the best way of clearing out a context menu is
most appreciated.
--Karthik
I have a contextmenu with each menu item comprising of a set of child
menus. This contextmenu is attached to an image control and is
displayed only when the user right-clicks on the image control. I am
having trouble in clearing out the contextmenu when the user
right-clicks and selects a menu option. What happens is that while the
contextmenu itself vanishes it leaves a small rectangular box on the
screen which only vanishes when I manually do an ALT-TAB into another
window and go back to my window with the contextmenu. The code I have
within the event handler of the menu option is as below:
'Somewhere, I attach an event handler to the menu
m.MenuItems.Add("&Event for Alarm ", New System.EventHandler(AddressOf
Me.JumpTo_OnClick))
..
..
..
'Event handler for the menu option
Protected Sub JumpTo_OnClick(ByVal sender As System.Object, ByVal e As
System.EventArgs)
...
For Each mnuItem As MenuItem In ContextMenu1.MenuItems
mnuItem.Enabled = False
mnuItem.Visible = False
mnuItem = Nothing
Next
ImageControl.ContextMenu = Nothing
ImageControl.Invalidate()
End Sub
Any suggestions as to the best way of clearing out a context menu is
most appreciated.
--Karthik