If you define the event on an interface, and make all your UserControls
implement that interface, you shouldn't need to use reflection to wire
up the events at all...

> -----Original Message-----
> From: Moderated discussion of advanced .NET topics.
> [mailto:[EMAIL PROTECTED]] On Behalf Of Keith Balaam
> Sent: Tuesday, July 02, 2002 7:23 AM
> To: [EMAIL PROTECTED]
> Subject: [ADVANCED-DOTNET] C# Wire up events using reflection
>
>
> My application dynamically adds UserControls to it's client
> area.  The UserControls fire events to update the container
> applications status bar. As the UserControls are added to the
> container I do the following to hook up the event:
>
> Type type = Ctrl.GetType();
> EventInfo ei = type.GetEvent("UpdateStatusBar");
> if (null != ei)
> {
>    ei.AddEventHandler(Ctrl, StatusBarEventHandler);
> }
>
> static void StatusBarEventHandler(object sender, EventArgs)
> {
>    ...
> }
>
> When I try to build the code I get the following error:
> "Method 'OMD.Core.OMDView.StatusBarEventHandler(object,
> System.EventArgs)' referenced without parentheses"
>
> Does anyone know what I'm doing wrong?
>
> You can read messages from the Advanced DOTNET archive,
> unsubscribe from Advanced DOTNET, or subscribe to other
> DevelopMentor lists at http://discuss.develop.com.
>
>

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to