Hello,

Does anybody know the possibility of routing different kind of events (Which
has different EventArgs like Click and OnPaint for example) to only one
handler sub?

I'm creating a designer control to allow the end users to design a form.The
user can drag new controls into this design surface and after the design I
move those controls to a normal windows form..At this point, I want to get
notified any of the events that those new controls will generate..And I
don't have predefind event subs already in my code which I can link those
controls...

Is there any possibility for this?

Thanks in Advance...

Özden

Re: Possibility to route different kind of events to only one handler? by James

James
Tue Jan 06 22:28:41 CST 2004

With .NET 2.0 you could use Generics...

But that doesn't help. I can't think of any other way of doing what you're
looking for off hand, although I'm sure you can do something like that with
reflection (I just don't know how without more research)

James Hancock

"Özden Irmak" <ozdenirmak@isnet.net.tr> wrote in message
news:O9WDEdJ1DHA.2680@TK2MSFTNGP11.phx.gbl...
> Hello,
>
> Does anybody know the possibility of routing different kind of events
> (Which
> has different EventArgs like Click and OnPaint for example) to only one
> handler sub?
>
> I'm creating a designer control to allow the end users to design a
> form.The
> user can drag new controls into this design surface and after the design I
> move those controls to a normal windows form..At this point, I want to get
> notified any of the events that those new controls will generate..And I
> don't have predefind event subs already in my code which I can link those
> controls...
>
> Is there any possibility for this?
>
> Thanks in Advance...
>
> Özden
>
>



Re: Possibility to route different kind of events to only one handler? by Howard

Howard
Wed Jan 07 13:40:16 CST 2004

All of the .Net base class event handlers derrive from the same signature.
So you could do something like:

void OnAnyEvent(object sender, EventArgs args)
{
if (args is PaintEventArgs)
{
PaintEventArgs paintArgs = (PaintEventArgs)args;
// do paint specific things
}
}

When you enumerate the events you should probably check the signature
because an event can have any parameters.



"Özden Irmak" <ozdenirmak@isnet.net.tr> wrote in message
news:O9WDEdJ1DHA.2680@TK2MSFTNGP11.phx.gbl...
> Hello,
>
> Does anybody know the possibility of routing different kind of events
(Which
> has different EventArgs like Click and OnPaint for example) to only one
> handler sub?
>
> I'm creating a designer control to allow the end users to design a
form.The
> user can drag new controls into this design surface and after the design I
> move those controls to a normal windows form..At this point, I want to get
> notified any of the events that those new controls will generate..And I
> don't have predefind event subs already in my code which I can link those
> controls...
>
> Is there any possibility for this?
>
> Thanks in Advance...
>
> Özden
>
>