How can I return the method that is called when an event is raised ?

How can I return the method that is called when an event is raised ?

System.Reflection.EventInfo.GetRaiseMethod does not work.

[129 byte] By [codefund.com] at [2007-12-20]
# 1
most controls and components have an events property which is a EventHandlerList class.

This in turn has an items property you can then get the method you want, I don't have any code samples since I'v never had to do this, but it does look feasible.

codefund.com at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms Designer...
# 2
most controls does not have EventHandlerList property like button, combobox ...

QUESTION ?

HOW CAN I RAISE ANY EVENT OF A CONTROL OR COMPONENT ?

codefund.com at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms Designer...
# 3
hi
I have same problem as u.
If u got ur answer please let me know how we can rasie an event belongs to a component
koosha at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms Designer...
# 4

I'm not sure if i understand it correctly but can't you just cal then on..... sub like onclick(e as clickeventargs) and onLoad(e as eventargs)

Remco

RemcoJVG at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms Designer...
# 5
Most of the events have different arguments. How you will know them to invoke event?
MikeChaliy at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms Designer...
# 6
In a designer you can get from an event descriptor to the method through the event binding service, see documentation at:

http://msdn2.microsoft.com/en-US/library/system.componentmodel.design.ieventbindingservice(VS.80).aspx

Use TypeDescriptor.GetEvents to get the event descriptors for the object. The IEventBindingService.GetEventProperty method returns a property descriptor for a string property, the value of which is the name of the method that will be called when the event is fired.

Obviously if you want to get the method at run-time you won't have an event binding service so as far as I know there is no standard way of doing that.

Edit:

Just realised from the context that what you want isn't "the method that is called when an event is raised" but the method that raises the event. As far as I know there is no standard way of getting this (which is generally a good thing IMO) but certain classes provide methods for raising specific events e.g. System.Windows.Form.Control.InvokeOnClick

simonl at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms Designer...