469,926 Members | 2,307 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

Set / Clear and restore control event handlers

Is there a way to get the event handlers such that I can cache the info
about handlers for a particular control, remove the handlers, do some code
and restore the cached event handlers in VB.NET (2008).

I would rather do things this way than having to have a boolean flag to
indicated to the handler to exit right away.

Psuedo code:

CacheHandlers(control)

code which would cause the control to fire an event.

RestoreHandlers(control).

LS

Jun 27 '08 #1
5 2775
RemoveHandler ....
...

code which would cause the control to fire an event.

AddHandler ....
...
"Lloyd Sheen" <a@b.cwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Is there a way to get the event handlers such that I can cache the info
about handlers for a particular control, remove the handlers, do some code
and restore the cached event handlers in VB.NET (2008).

I would rather do things this way than having to have a boolean flag to
indicated to the handler to exit right away.

Psuedo code:

CacheHandlers(control)

code which would cause the control to fire an event.

RestoreHandlers(control).

LS
Jun 27 '08 #2

"Stephany Young" <noone@localhostwrote in message
news:Oh**************@TK2MSFTNGP04.phx.gbl...
RemoveHandler ....
...

code which would cause the control to fire an event.

AddHandler ....
...
"Lloyd Sheen" <a@b.cwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>Is there a way to get the event handlers such that I can cache the info
about handlers for a particular control, remove the handlers, do some
code and restore the cached event handlers in VB.NET (2008).

I would rather do things this way than having to have a boolean flag to
indicated to the handler to exit right away.

Psuedo code:

CacheHandlers(control)

code which would cause the control to fire an event.

RestoreHandlers(control).

LS
Yes I know about the "norm" but what I am looking at doing is for a control
(any control) to have a way of removing and then after some code restoring
the event handlers. I am looking for a general method which would take into
account that I would not know what to use for Addhandler and RemoveHandler
so I am looking for a method to enumerate the "added" handlers and then
cache the info, do a remove and when asked reset using AddHandler.

LS

Jun 27 '08 #3
Lloyd,

You will need reflection for what you want, however in my idea are you going
in the wrong direction.

Cor

"Lloyd Sheen" <a@b.cschreef in bericht
news:%2****************@TK2MSFTNGP05.phx.gbl...
>
"Stephany Young" <noone@localhostwrote in message
news:Oh**************@TK2MSFTNGP04.phx.gbl...
> RemoveHandler ....
...

code which would cause the control to fire an event.

AddHandler ....
...
"Lloyd Sheen" <a@b.cwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>Is there a way to get the event handlers such that I can cache the info
about handlers for a particular control, remove the handlers, do some
code and restore the cached event handlers in VB.NET (2008).

I would rather do things this way than having to have a boolean flag to
indicated to the handler to exit right away.

Psuedo code:

CacheHandlers(control)

code which would cause the control to fire an event.

RestoreHandlers(control).

LS

Yes I know about the "norm" but what I am looking at doing is for a
control (any control) to have a way of removing and then after some code
restoring the event handlers. I am looking for a general method which
would take into account that I would not know what to use for Addhandler
and RemoveHandler so I am looking for a method to enumerate the "added"
handlers and then cache the info, do a remove and when asked reset using
AddHandler.

LS
Jun 27 '08 #4
Seems pretty easy if this is what you are looking for :-)
http://msdn.microsoft.com/en-us/libr...ationlist.aspx
MyEventEvent.GetInvocationList()
HTH

Michel Posseth


"Lloyd Sheen" <a@b.cschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl...
Is there a way to get the event handlers such that I can cache the info
about handlers for a particular control, remove the handlers, do some code
and restore the cached event handlers in VB.NET (2008).

I would rather do things this way than having to have a boolean flag to
indicated to the handler to exit right away.

Psuedo code:

CacheHandlers(control)

code which would cause the control to fire an event.

RestoreHandlers(control).

LS

Jun 27 '08 #5

"Michel Posseth [MCP]" <MS**@posseth.comwrote in message
news:Oz**************@TK2MSFTNGP03.phx.gbl...
Seems pretty easy if this is what you are looking for :-)
http://msdn.microsoft.com/en-us/libr...ationlist.aspx
MyEventEvent.GetInvocationList()
HTH

Michel Posseth


"Lloyd Sheen" <a@b.cschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl...
>Is there a way to get the event handlers such that I can cache the info
about handlers for a particular control, remove the handlers, do some
code and restore the cached event handlers in VB.NET (2008).

I would rather do things this way than having to have a boolean flag to
indicated to the handler to exit right away.

Psuedo code:

CacheHandlers(control)

code which would cause the control to fire an event.

RestoreHandlers(control).

LS

Thanks but I would like to go from the other direction. I would like to get
a list of the eventhandlers (not eventinfo) for a control which would allow
me to remove the handlers from certain events and add them after I execute
some code. Is that at all possible?

I notice that Control thru the base class Component has a Events property.
This unfortunately is protected so I cannot get the list from here. I want
to start a control not at delegate since I might not know the delegate(s).

Thanks
LS

Jun 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by pagates | last post: by
1 post views Thread by clickon | last post: by
reply views Thread by \(O\)enone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.