473,804 Members | 5,054 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unregistering events

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
Nov 15 '05 #1
6 13246
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.s i> 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

Nov 15 '05 #2
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.KeyPres sed += ...

and when I want to unregister it:
TextBox.KeyPres sed -=

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()
{
UnregisterEvent s();
}
}

Thanks,
saso

"William Ryan" <do********@nos pam.comcast.net > wrote in message
news:%2******** ********@TK2MSF TNGP09.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.s i> 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


Nov 15 '05 #3
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...tha t'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=glanc e&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.s i> 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.KeyPres sed += ...

and when I want to unregister it:
TextBox.KeyPres sed -=

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()
{
UnregisterEvent s();
}
}

Thanks,
saso

"William Ryan" <do********@nos pam.comcast.net > wrote in message
news:%2******** ********@TK2MSF TNGP09.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.s i> 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



Nov 15 '05 #4
Hello

To unregister all events of a control, simply dispose the Events List

this.Events.Dis pose();

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.s i> 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

Nov 15 '05 #5
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.NO SPAM> wrote in message
news:eP******** ******@tk2msftn gp13.phx.gbl...
Hello

To unregister all events of a control, simply dispose the Events List

this.Events.Dis pose();

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.s i> 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


Nov 15 '05 #6
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.NO SPAM> wrote in message
news:eP******** ******@tk2msftn gp13.phx.gbl...
Hello

To unregister all events of a control, simply dispose the Events List

this.Events.Dis pose();

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/cpcondefiningcu stomevent.asp

Best regards,

Sherif

"Saso Zagoranski" <sa************ *@guest.arnes.s i> 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


Nov 15 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1750
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 ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. The following information is part of the event: Finish unregistering ASP.NET (version...
3
2039
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 DataNode is changed, it raises "Changed" event. The class has a reference to the DataNode it is being contained in: - DataTree - tree like data structure that contains DataNodes; When
14
12155
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 events since I never saw it used anywhere in MSDN documentation/samples?! Or it will just break when I upgrade to .NET Framework 2.x in the coming years namespace MyNamespac public delegate void MyDel() public class MyBase public virtual...
1
3265
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 /unregister after unregistering, I thought the keys and values that
4
22893
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 when to use one over another? If anyone could provide any additional info, your comments, best practices, any good articles, specific examples, etc. Thank you
11
1887
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 mean, for one, delegates point to subs, so when you call a delegate, why not just call the sub dierectly and not bother adding the extra code involved adding the delegate?
3
2328
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: p1.FirstNameChanged -= new Person.NameChanged(p1_FirstNameChanged); The above line that removes the delegate confuses me. It works - buy why must we use the 'new' keyword? The delegate already exists and is "registered" with the event. I would think...
14
2224
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, EventTimeBegin, Category FROM Events WHERE EventDateBegin >'01/01/2008' AND Events.Category LIKE '3' OR Events.Category LIKE '4' OR Events.Category LIKE '5' OR Events.Category LIKE '6' OR Events.Category LIKE '7' OR Events.Category LIKE '8' OR...
1
4911
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 events when click on that date that perticular event displyed in a text box.But my requirement is to when click on that date that related event displyed in same td row not the text box. and also i add the events to that calendar.plz advice how to...
0
9579
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
10577
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...
0
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9150
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6853
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
5521
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...
1
4299
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
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2991
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.