addhandler question

E

EMW

I use the following code in the POPUP event of a contextmenu:

mnuItem = New MenuItem
mnuItem.Text = "Shelter"
cmThs.MenuItems.Add(mnuItem)
AddHandler mnuItem.Click, AddressOf MenuItemClicked
mnuItem = New MenuItem
mnuItem.Text = "Building"
cmThs.MenuItems.Add(mnuItem)
AddHandler mnuItem.Click, AddressOf MenuItemClicked
mnuItem = New MenuItem
mnuItem.Text = "Bsc"
cmThs.MenuItems.Add(mnuItem)
AddHandler mnuItem.Click, AddressOf MenuItemClicked


MenuItemClicked is a function in the same form.

It works fine, but I'm having strange problems I''m wandering if this is the
reason of it.
Simulair code is used for each textbox where the contextmenu is activated.

Now how do I remove all the handlers that were created.
I want to do this in the MenuItemClicked, because after that the handler is
not needed anymore untill the user activates the contextmenu again.
Is there some of way of removing all EventHandlers pointing to a specific
procedure?

rg,
Eric
 

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

Similar Threads


Top