473,396 Members | 2,037 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,396 software developers and data experts.

EventHandler

Hi!
I need to know if an event (i.e. button1_click) has an eventhandler
associated. Is this possible in c#?

Thanks,

Matias
Nov 15 '05 #1
3 3319
Matias,

It isn't really possible. What you would have to do is keep a record of
when the method is used for an event handler by overriding the event itself
to store when a method is used and even then, you can't override types
beyond your control to get that functionality.

What exactly are you trying to do?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Matias Szulman" <ma****@nospam.orkon.com> wrote in message
news:Oj**************@tk2msftngp13.phx.gbl...
Hi!
I need to know if an event (i.e. button1_click) has an eventhandler
associated. Is this possible in c#?

Thanks,

Matias

Nov 15 '05 #2
I have a menu with menu items with different hierachies (for example, the
menus within outlook express). Now some of them have eventhandlers for some
events, but some don't (in OE, the MENU item in File does not have an
eventhandler for the click event, while the MESSAGE item under MENU under
FILE does have). I suppose it's hard to explain, but what I need to do is to
create a treenode with a node for each menu item that has en eventhandler
for the click event.

Thanks in advance,

Matias
Nov 15 '05 #3
Matias,
In addition to Nicholas's comments.
I need to know if an event (i.e. button1_click) has an eventhandler
associated. Is this possible in c#? Are you asking does the Click event of the Button1 object have any handlers?

Remember that an event in implemented in terms of a Delegate. If the
Delegate is null there are no handlers, if the Delegate is not null there
are handlers.

http://msdn.microsoft.com/library/de...guidelines.asp

If you are interested in the number of handlers, the Delegate has a
GetInvocationList method that returns the list of methods associated with
the delegate. Hence you can use GetInvocationList to get the number of
handlers associated with the event.

The problem you are going to run into, for classes that are not your own
design (Button for example) the above Delegate is private.

Hope this helps
Jay
"Matias Szulman" <ma****@nospam.orkon.com> wrote in message
news:Oj**************@tk2msftngp13.phx.gbl... Hi!
I need to know if an event (i.e. button1_click) has an eventhandler
associated. Is this possible in c#?

Thanks,

Matias

Nov 15 '05 #4

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

Similar topics

2
by: Sandor Heese | last post by:
Question, When using BeginInvoke (on a From to marshal to the UI thread) with the EventHandler delegate I see some strange behaviour. The problem is that I call the UpdateTextBox method with a...
3
by: Remco | last post by:
Hello, Serverside I'm generating a html page. There are different controls for which I want to create an eventhandler manually. Like: document.forms.TextBox1.onchange = EventHandler;...
0
by: dominosly | last post by:
Okay, this is a rather complicated problem, so here is the short of it: I am using a custom designed user control that simply writes out a plain old html submit button to the page. When the...
12
by: aplaxas | last post by:
Hi! "CDemo.Call" eventHandler is added to "button3.click" Event when both button1 and button2 are clicked. However, I want to add "cd.Call" only one time even though I clicked both button1 and...
5
by: JMWilton | last post by:
Is there a way to determine what has been added to the eventhandler list? I have code that uses += and -= to turn event handling code on and off. Apparently, it is possible to add the same event...
4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
9
by: Christopher Weaver | last post by:
Can anyone tell me how I could iterate through a collection of controls on a form while assigning their event handlers to another identical collection of controls on the same form. So far,...
13
by: jac | last post by:
Hae, I have a windows form with a ComboBox an other things. On that combobox I have an eventhandler on de selectedindexchanged. But somewhere in my code want to do excecute the same code that...
2
by: mawi | last post by:
Hi there, When removing page children controls created dynamically not in last-to-first order, the close button of the last control looses its event wiring, even though the handler is rewired...
2
cornfed
by: cornfed | last post by:
I've got a class to make Templates for different repeaters in my page. in one of these repeaters a linkbutton is needed. This LinkButton needs an event that is in a .cs file somewhere else in the...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
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
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...
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,...
0
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...
0
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...
0
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...

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.