Hi!
How can I unregister all the events registered to a control?
I have seen a piece of code in another thread, which gets all the registered
handlers for a specific event.
Let's say I have a CustomTextBox : TextBox, which has quite a lot of
events...
Do I put unregistering code for all the possible events in the Dispose
method? Or is there another way?
Could someone please provide just a simple example of this?
Thank,
Saso 6 13218
The Supreme All-Knowing Guru of all things .NET discusses this in depth
here.. http://msdn.microsoft.com/msdnmag/is...t/default.aspx
Here's different one... http://www.csharp-station.com/Tutorials/Lesson14.pdf that you may find
helpful.
Cheers,
Bill
"Saso Zagoranski" <sa*************@guest.arnes.si> wrote in message
news:bo**********@planja.arnes.si... Hi!
How can I unregister all the events registered to a control? I have seen a piece of code in another thread, which gets all the
registered handlers for a specific event.
Let's say I have a CustomTextBox : TextBox, which has quite a lot of events... Do I put unregistering code for all the possible events in the Dispose method? Or is there another way?
Could someone please provide just a simple example of this?
Thank, Saso
Thanks for answering!
First off... "The Supreme All-Knowing Guru" ?? :)
As far as I understand the articles they discuss unregistering the event
from the object, which handles the event...
e.g. If I have a Form and a TextBox I would have something like:
TextBox.KeyPressed += ...
and when I want to unregister it:
TextBox.KeyPressed -=
What I would like to know is, whether it is possible to unregister the event
from the TextBox... e.g. when I'm calling
the Dispose() method of the textbox I would like to unregister all the
events...
class TextBox
{
...
protected override void Dispose()
{
UnregisterEvents();
}
}
Thanks,
saso
"William Ryan" <do********@nospam.comcast.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... The Supreme All-Knowing Guru of all things .NET discusses this in depth here.. http://msdn.microsoft.com/msdnmag/is...t/default.aspx
Here's different one... http://www.csharp-station.com/Tutorials/Lesson14.pdf that you may find helpful.
Cheers,
Bill "Saso Zagoranski" <sa*************@guest.arnes.si> wrote in message news:bo**********@planja.arnes.si... Hi!
How can I unregister all the events registered to a control? I have seen a piece of code in another thread, which gets all the registered handlers for a specific event.
Let's say I have a CustomTextBox : TextBox, which has quite a lot of events... Do I put unregistering code for all the possible events in the Dispose method? Or is there another way?
Could someone please provide just a simple example of this?
Thank, Saso
Jeffery Richter of Wintellect..he's one of the founders of it and probably
one of the most impressive .NET guys going (IMHO).
As far as disposing...that's a good question. not sure off of the top of my
head, but an interesting proposition. Let me play with it and see what I
can come up with.
BTW, if you haven't read any of Jeffrey's stuff..he has one fo the best
books on .NET I've read..
( http://www.amazon.com/exec/obidos/tg...1068333345/sr=
8-1/ref=sr_8_1/103-3171781-7147053?v=glance&n=507846) and his articles on
Delegates are like manna from Heaven...( http://www.wintellect.com/resources/...spx?authorID=3 )
I'll play with it and get back to you shortly...
"Saso Zagoranski" <sa*************@guest.arnes.si> wrote in message
news:bo**********@planja.arnes.si... Thanks for answering!
First off... "The Supreme All-Knowing Guru" ?? :)
As far as I understand the articles they discuss unregistering the event from the object, which handles the event... e.g. If I have a Form and a TextBox I would have something like: TextBox.KeyPressed += ...
and when I want to unregister it: TextBox.KeyPressed -=
What I would like to know is, whether it is possible to unregister the
event from the TextBox... e.g. when I'm calling the Dispose() method of the textbox I would like to unregister all the events... class TextBox { ... protected override void Dispose() { UnregisterEvents(); } }
Thanks, saso
"William Ryan" <do********@nospam.comcast.net> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... The Supreme All-Knowing Guru of all things .NET discusses this in depth here.. http://msdn.microsoft.com/msdnmag/is...t/default.aspx
Here's different one... http://www.csharp-station.com/Tutorials/Lesson14.pdf that you may find helpful.
Cheers,
Bill "Saso Zagoranski" <sa*************@guest.arnes.si> wrote in message news:bo**********@planja.arnes.si... Hi!
How can I unregister all the events registered to a control? I have seen a piece of code in another thread, which gets all the registered handlers for a specific event.
Let's say I have a CustomTextBox : TextBox, which has quite a lot of events... Do I put unregistering code for all the possible events in the Dispose method? Or is there another way?
Could someone please provide just a simple example of this?
Thank, Saso
Hello
To unregister all events of a control, simply dispose the Events List
this.Events.Dispose();
This works for the control's inherited events. If your control has custom
events defined by you, either make sure they use the Events list or
unregister them yourself using the -= syntax.
To find out how to use the Events list for your own events read the
"Optimizing Event Implementation" section in the following page: http://msdn.microsoft.com/library/de...ustomevent.asp
Best regards,
Sherif
"Saso Zagoranski" <sa*************@guest.arnes.si> wrote in message
news:bo**********@planja.arnes.si... Hi!
How can I unregister all the events registered to a control? I have seen a piece of code in another thread, which gets all the
registered handlers for a specific event.
Let's say I have a CustomTextBox : TextBox, which has quite a lot of events... Do I put unregistering code for all the possible events in the Dispose method? Or is there another way?
Could someone please provide just a simple example of this?
Thank, Saso
Sherif:
I think his question was on unregistering a single event, but I may be
wrong. Either way, you make an excellent point here b/c using
Events.Dispose gives you the ability to get rid of everything at once and
that can be a real time saver in many instances. I was thinking in single
event mode, but you often need to get rid of everything, and the method you
mention is definitely an elegant implementation.
"Sherif ElMetainy" <el*************@wayout.net.NOSPAM> wrote in message
news:eP**************@tk2msftngp13.phx.gbl... Hello
To unregister all events of a control, simply dispose the Events List
this.Events.Dispose();
This works for the control's inherited events. If your control has custom events defined by you, either make sure they use the Events list or unregister them yourself using the -= syntax.
To find out how to use the Events list for your own events read the "Optimizing Event Implementation" section in the following page: http://msdn.microsoft.com/library/de...ustomevent.asp
Best regards,
Sherif
"Saso Zagoranski" <sa*************@guest.arnes.si> wrote in message news:bo**********@planja.arnes.si... Hi!
How can I unregister all the events registered to a control? I have seen a piece of code in another thread, which gets all the registered handlers for a specific event.
Let's say I have a CustomTextBox : TextBox, which has quite a lot of events... Do I put unregistering code for all the possible events in the Dispose method? Or is there another way?
Could someone please provide just a simple example of this?
Thank, Saso
I just want to dispose all the events register for a button control. But I
didn't find Events property for that button.
How can i do that?
-chandu.
"Sherif ElMetainy" <el*************@wayout.net.NOSPAM> wrote in message
news:eP**************@tk2msftngp13.phx.gbl... Hello
To unregister all events of a control, simply dispose the Events List
this.Events.Dispose();
This works for the control's inherited events. If your control has custom events defined by you, either make sure they use the Events list or unregister them yourself using the -= syntax.
To find out how to use the Events list for your own events read the "Optimizing Event Implementation" section in the following page: http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpcondefiningcustomevent.asp
Best regards,
Sherif
"Saso Zagoranski" <sa*************@guest.arnes.si> wrote in message news:bo**********@planja.arnes.si... Hi!
How can I unregister all the events registered to a control? I have seen a piece of code in another thread, which gets all the registered handlers for a specific event.
Let's say I have a CustomTextBox : TextBox, which has quite a lot of events... Do I put unregistering code for all the possible events in the Dispose method? Or is there another way?
Could someone please provide just a simple example of this?
Thank, Saso
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Les Caudle |
last post by:
After removing the .NET Framework (so that I can install the 1.1 Framework), I
get the following error msg in the event log:
The description for Event ID ( 1071 ) in Source ( ASP.NET 1.0.3705.288...
|
by: Sasha |
last post by:
Hi everyone,
Here is my problem:
I have the following classes:
- DataNode - this class is designed to hold some data and will be contained
in a tree like data structure DataTree. When...
|
by: JPRoot |
last post by:
Hi
I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using...
|
by: |
last post by:
Hi all
I am using RegAsm.exe to register .NET assemblies like
this:
regasm D:\...\...\MyDLL.dll /tlb:d:\mybin\MyDLL.tlb
for unregistering:
regasm
D:\...\...\MyDLL.dll /tlb:d:\mybin\MyDLL.tlb...
|
by: LP |
last post by:
Hello!
I am still transitioning from VB.NET to C#. I undertand the basic concepts
of Delegates, more so of Events and somewhat understand AsyncCallback
methods. But I need some clarification on...
|
by: Nicky Smith |
last post by:
Hello,
I'm studying a book on VB.net Win apps, and I'm reading a section on
events and delegates and raising events.
Is it just me, or is this not just subs dressed up as something else?
I...
|
by: Jeff S |
last post by:
Please consider this sample code: It registers a delegate with an event.
p1.FirstNameChanged += new Person.NameChanged(p1_FirstNameChanged);
Now the following code removes the delegate:...
|
by: xoozlez |
last post by:
Hi there,
I have a registration form where I like to filter out the past events of 2007. This is the code I am using :
strSQL = "SELECT EventID, EventName, EventDateBegin, EventDateEnd,...
|
by: swethak |
last post by:
Hi,
I am desiging the calendar application for that purpose i used the below code. But it is for only displys calendar. And also i want to add the events to calendar. In that code displys the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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,...
| |