How Remove All Handler on a event?

  • Thread starter Thread starter Franky
  • Start date Start date
F

Franky

How Remove All Handler on a event?
Like remove all handler on the myButton.Click.


Thanks

______________________________
Franky
(e-mail address removed)
 
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
 
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
 
* "Franky said:
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.
 
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
 
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 ) said:
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
 
* "One Handed Man \( OHM - Terry Burns \) said:
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.
 
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.
 
* David said:
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.
 
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
 
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.
 

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

Back
Top