473,659 Members | 2,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(c ontrol)

code which would cause the control to fire an event.

RestoreHandlers (control).

LS

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

code which would cause the control to fire an event.

AddHandler ....
...
"Lloyd Sheen" <a@b.cwrote in message
news:%2******** ********@TK2MSF TNGP02.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(c ontrol)

code which would cause the control to fire an event.

RestoreHandlers (control).

LS
Jun 27 '08 #2

"Stephany Young" <noone@localhos twrote in message
news:Oh******** ******@TK2MSFTN GP04.phx.gbl...
RemoveHandler ....
...

code which would cause the control to fire an event.

AddHandler ....
...
"Lloyd Sheen" <a@b.cwrote in message
news:%2******** ********@TK2MSF TNGP02.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.

RestoreHandler s(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******** ********@TK2MSF TNGP05.phx.gbl. ..
>
"Stephany Young" <noone@localhos twrote in message
news:Oh******** ******@TK2MSFTN GP04.phx.gbl...
> RemoveHandler ....
...

code which would cause the control to fire an event.

AddHandler ....
...
"Lloyd Sheen" <a@b.cwrote in message
news:%2******* *********@TK2MS FTNGP02.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.

RestoreHandle rs(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.Ge tInvocationList ()
HTH

Michel Posseth


"Lloyd Sheen" <a@b.cschreef in bericht
news:%2******** ********@TK2MSF TNGP02.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(c ontrol)

code which would cause the control to fire an event.

RestoreHandlers (control).

LS

Jun 27 '08 #5

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

Michel Posseth


"Lloyd Sheen" <a@b.cschreef in bericht
news:%2******** ********@TK2MSF TNGP02.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.

RestoreHandler s(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
1516
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 lets say two events: ItemCheck and DataSourceChange. Callbacks assigned to ItemCheck and DataSourceChange
0
1057
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 AfterLabelEdit, BeforeLabelEdit, and ItemDrag events (just to use some events as an example). If I remove this tree control programatically, and then add it back in with a different parent, I've lost the event handlers. I'd like to recreate these
1
1972
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 point out the really obvious and stupid thing I'm overlooking here. :) I have a custom control that provides a tasklist similar to what you get in certain parts of Office. On the client it consists of a bunch of nested, named and id'ed divs with...
11
1894
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 other handles a custom "CardInserted" event for a class I wrote that watches for smart cards to be inserted into an attached smart card reader.
2
15445
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 events allowing the user control to react to the mouse click. Setting the Enabled property on the label to False comes close, but I don't want the font color to change. Does anyone have an idea how .NET implements the code behind the Enabled...
1
5133
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 the two steps, TextBox1.Text ="foo"; and TextBox2.Text = "bar";
5
25769
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 know how to clear up them? Thanks BTW: I do not know what specific event handlers are attached, so I cannot use Banner_MouseDoubleClick -= XXX to unregister it.
0
1010
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 new control to hook up all the event handlers. As I already have an initial control on my form with all the event handlers applied by the underlying source code, is there any way I can loop through all of the event handlers for that control and...
0
236
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 equivalent of removing the handler while some code is executed and then restoring it when the code is finished. The best example would be a simple app with a navigation area and a details area. I have in the navigation two listboxes. The first is...
0
8330
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8626
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.