Keith,
Try
ei.AddEventHandler(Ctrl, new EventHandler(this.StatusBarEventHandler));
That is, you have to wrap the event-handling method in a event-handler. So, the
delegate itsself is *not* the event handler.
HTH,
Stefan
----- Original Message -----
From: "Keith Balaam" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "Keith Balaam" <[EMAIL PROTECTED]>
Sent: Tuesday, July 02, 2002 2:22 PM
Subject: 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.