Heiko
Contributor
Don't know if this is language specific, so please move if required.
Scenario:
Loads of UserControls with loads of "IExtendedControls" on them, which are often added at runtime.
IExtendedControls can raise an Event "ShowHistory (Sender as Object, e as ShowHistoryEventArgs)".
Quite naturally I do not want to manually add handlers to each and every IExtendedControl. I am doing this with a helper class, which will receive a root-control, a delegate and the will recurse through the root-controls control collection, check if the collection members implement IExtended and add the handler.
Now this:
Most Probably "ShowHistory" will not remain the only event that I want to fetch. So it would be quite convenient if I could also dynamically pass the event to the helper class.
I don't see this is possible within the framework.
Maybe I could pass the Event "ByName" and then use System.Reflection to find out, if an object can raise the desired event. Still I don't have a way to describe this event in an
AddHandler Object as Event, Object as Delegate
statement. (VB.NET says, there is no such type as "Event")
Scenario:
Loads of UserControls with loads of "IExtendedControls" on them, which are often added at runtime.
IExtendedControls can raise an Event "ShowHistory (Sender as Object, e as ShowHistoryEventArgs)".
Quite naturally I do not want to manually add handlers to each and every IExtendedControl. I am doing this with a helper class, which will receive a root-control, a delegate and the will recurse through the root-controls control collection, check if the collection members implement IExtended and add the handler.
Now this:
Most Probably "ShowHistory" will not remain the only event that I want to fetch. So it would be quite convenient if I could also dynamically pass the event to the helper class.
I don't see this is possible within the framework.
Maybe I could pass the Event "ByName" and then use System.Reflection to find out, if an object can raise the desired event. Still I don't have a way to describe this event in an
AddHandler Object as Event, Object as Delegate
statement. (VB.NET says, there is no such type as "Event")