473,898 Members | 2,956 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 3112
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
1539
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
1075
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
1987
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
1909
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
15468
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
5143
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
25814
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
1025
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
9993
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11259
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10948
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10483
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
8035
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
7187
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
5880
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
6076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4706
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

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.