473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 3022
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Serge Shimanovsky | last post by:
Hi, I have a situation where I need to clear the event sinks from an event. But let's say I don't know which methods (by name, I mean) signed up for that event. I do have a control with...
0
by: pagates | last post by:
Hi All, Is there any way to get the list of events that a particular control handles, so they can be added or removed dynamically? In other words, say I have a TreeView that handles the...
1
by: Lamont Adams | last post by:
Hi all, I've created numerous custom controls of varying complexity, but I've been on this problem for a day and a half, and I can't figure this mystery out. I hope one of you kind folks can...
11
by: BoloBaby | last post by:
OK, check this out... I have a form with a panel control and button on it (outside the panel control). I have two event handlers - one handles the click event of the button on the form. The...
2
by: bretth | last post by:
In a VB.Net Windows Forms application, I have a user control that handles mouse events. Another section of code programmatically adds a label to the control. I would like label to ignore all...
1
by: clickon | last post by:
For testing purposes i have got a 2 step WizardControl. Eqach step contains a text box, TextBox1 and TextBox2 respectively. If i put the following code in the respective activate event handlers for...
5
by: zlf | last post by:
I have an UserControl created by other component, its creator attachs some event handlers to MouseDoubleClick event, but I do not like those events to be triggered while it is db-clicked. I want to...
0
by: \(O\)enone | last post by:
I'm working on some code which dynamically adds WinForms controls to a form. It's all working well but I'm having to manually call AddHandler repeatedly for each event I am using each time I add...
0
by: Lloyd Sheen | last post by:
1st let me apologize for creating new thread but using Windows Mail and old one is gone all read. What I was asking if there was a "generic" method of capturing control events and doing the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.