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

How Remove All Handler on a event?

P: n/a
How Remove All Handler on a event?
Like remove all handler on the myButton.Click.
Thanks

______________________________
Franky
Fr***************@hotmail.com
Nov 21 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
RemoveHandler Button1.Click, AddressOf Button1_Click
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Franky" <fr***************@hotmail.com> wrote in message
news:uA****************@TK2MSFTNGP15.phx.gbl...
How Remove All Handler on a event?
Like remove all handler on the myButton.Click.
Thanks

______________________________
Franky
Fr***************@hotmail.com

Nov 21 '05 #2

P: n/a
Yes if they have ONE handler call Button1_Click...

But if the handler is not Button1_Click but something else or iy they have 2
or 3 handler?

How can you Remove all Handler ?

Franky

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:u%****************@TK2MSFTNGP15.phx.gbl...
RemoveHandler Button1.Click, AddressOf Button1_Click
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Franky" <fr***************@hotmail.com> wrote in message
news:uA****************@TK2MSFTNGP15.phx.gbl...
How Remove All Handler on a event?
Like remove all handler on the myButton.Click.
Thanks

______________________________
Franky
Fr***************@hotmail.com


Nov 21 '05 #3

P: n/a
* "Franky" <fr***************@hotmail.com> scripsit:
How Remove All Handler on a event?
Like remove all handler on the myButton.Click.


If you are defining the event yourself:

Let's assume that you defined the 'Foo' event. Then VB.NET will
generate a delegate variable called 'FooEvent' automatically. This
variable provides a 'GetInvocationList' method that can be used to get
all the handlers connected to the event. You can use the delegate's
'Remove' method to remove one delegate connected to the event after the
other.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #4

P: n/a
No he's asking for a list of Handler associated with the instance of a class
so he do something like.
ForEach handler in object.MyHandlers

removeHandler . . . . . . .
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OD****************@tk2msftngp13.phx.gbl...
* "Franky" <fr***************@hotmail.com> scripsit:
How Remove All Handler on a event?
Like remove all handler on the myButton.Click.


If you are defining the event yourself:

Let's assume that you defined the 'Foo' event. Then VB.NET will
generate a delegate variable called 'FooEvent' automatically. This
variable provides a 'GetInvocationList' method that can be used to get
all the handlers connected to the event. You can use the delegate's
'Remove' method to remove one delegate connected to the event after the
other.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5

P: n/a
No he's asking for a list of Handlers associated with the instance of a
class
so he does something like.

(see above post )

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:uT*************@TK2MSFTNGP09.phx.gbl...
No he's asking for a list of Handler associated with the instance of a class so he do something like.
ForEach handler in object.MyHandlers

removeHandler . . . . . . .
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OD****************@tk2msftngp13.phx.gbl...
* "Franky" <fr***************@hotmail.com> scripsit:
How Remove All Handler on a event?
Like remove all handler on the myButton.Click.


If you are defining the event yourself:

Let's assume that you defined the 'Foo' event. Then VB.NET will
generate a delegate variable called 'FooEvent' automatically. This
variable provides a 'GetInvocationList' method that can be used to get
all the handlers connected to the event. You can use the delegate's
'Remove' method to remove one delegate connected to the event after the
other.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #6

P: n/a
* "One Handed Man \( OHM - Terry Burns \)" <news.microsoft.com> scripsit:
No he's asking for a list of Handler associated with the instance of a class
so he do something like.
Sure, that's what my answer is about.
ForEach handler in object.MyHandlers

removeHandler . . . . . . .


My answer shows how to determine the handlers added to an event.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #7

P: n/a
On 2004-08-26, One Handed Man ( OHM - Terry Burns ) <> wrote:
No he's asking for a list of Handler associated with the instance of a class
so he do something like.
ForEach handler in object.MyHandlers

removeHandler . . . . . . .


I'm not sure I'm putting together your two posts correctly. What's
object.MyHandlers in the above, I've never seen anything like that
before?

To the original poster, the short answer is that in the general case you
can't do this. You can't clear somebody else's invocation list (in this
case, the Button's invocation list). However, usually buttons only have
handlers on the current form and it's not too difficult to keep track of
those, so maybe that's enough for you.

Nov 21 '05 #8

P: n/a
* David <df*****@woofix.local.dom> scripsit:
No he's asking for a list of Handler associated with the instance of a class
so he do something like.
ForEach handler in object.MyHandlers

removeHandler . . . . . . .


I'm not sure I'm putting together your two posts correctly. What's
object.MyHandlers in the above, I've never seen anything like that
before?


I assume it's pseudo-code. Nevertheless, there is no such property.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #9

P: n/a
It is Pseudo code, I'm just trying to illustrate the need of the OP, not
offering a solution

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
* David <df*****@woofix.local.dom> scripsit:
No he's asking for a list of Handler associated with the instance of a class so he do something like.
ForEach handler in object.MyHandlers

removeHandler . . . . . . .


I'm not sure I'm putting together your two posts correctly. What's
object.MyHandlers in the above, I've never seen anything like that
before?


I assume it's pseudo-code. Nevertheless, there is no such property.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #10

P: n/a
On 2004-08-26, One Handed Man ( OHM - Terry Burns ) <> wrote:
It is Pseudo code, I'm just trying to illustrate the need of the OP, not
offering a solution


Ahh, thanks. I assumed it might be, but then you said your post got
mangled so I thought I might be missing something.
Nov 21 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.