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 2 1567
Eric,
MenuItem is a part of the MenuItemCollection, in my opinion it should be
therefore very easy to do with a (see this as pseudo not tested and typed
here) to do what I thought that you where asking.
for each MnIt as MenuItem in cmThs.MenuItems
RemoveHandler MnIt.Click, AddressOf MenuItemClicked
next
I hope that this helps?
Cor
"EMW" <so*****@MikroZoft.com> 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
Hi Cor,
I also managed to solve this.
I used an array of menuitems to store each created menuitem and then in the
MenuItemClicked routine I called RemoveHandler on each arrayItem.
rg.
Eric
"Cor Ligthert" <no************@planet.nl> schreef in bericht
news:OI**************@TK2MSFTNGP12.phx.gbl... Eric,
MenuItem is a part of the MenuItemCollection, in my opinion it should be therefore very easy to do with a (see this as pseudo not tested and typed here) to do what I thought that you where asking.
for each MnIt as MenuItem in cmThs.MenuItems RemoveHandler MnIt.Click, AddressOf MenuItemClicked next
I hope that this helps?
Cor
"EMW" <so*****@MikroZoft.com>
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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: EMW |
last post by:
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...
|
by: Jeffrey A. Voigt |
last post by:
Can someone take a quick glace at my code and tell me why my
AutoPostBackHandler function does not get fired off at all? What I'm trying
to do is get all of the Buttons and DropDownList controls...
|
by: DJ |
last post by:
Good morning,
Still new at this so please bear with me. I am creating a table dynamically
using webcontrols based on the output of a sproc from my database.The table
represents test instances...
|
by: Just Me |
last post by:
When a document is to be printed I call a method that contains an AddHandler
statement.
I just realized that if a second copy is to be printed the method is called
and the AddHandler is executed...
|
by: EMW |
last post by:
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...
|
by: hartley_aaron |
last post by:
Hi,
I was trying to store the address of the my current handler for a
particular event so as to simplify using AddHandler and RemoveHandler
throughout my code. However, I cannot seem to get any...
|
by: Tom |
last post by:
I use dynamically created controls all the time. I.E. I create the
control in code then use AddHandler to add the necessary delegates for
processing (like Click, etc).
Does one have to call...
|
by: Nathan Sokalski |
last post by:
I have a section of my code that dynamically creates LinkButtons to allow
the user to go to the page containing a question they have not answered. The
code that creates the LinkButton is called, as...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |