Re: Cascading delegates
- From: Amien Crombie <acrombie@xxxxxxxxxxx>
- Date: Tue, 21 Apr 2009 17:50:04 +0200
Ben Voigt [C++ MVP] wrote:
Hi Ben
"Amien Crombie" <acrombie@xxxxxxxxxxx> wrote in message news:exMuXByvJHA.5584@xxxxxxxxxxxxxxxxxxxxxxxHi
I have a Usercontrol (child) that is part of another usercontrol (Parent). In my child usercontrol, I use a delegate to pass an event with some data (a custom EventArgs class) to the parent usercontrol. This parent usercontrol then creates a duplicate delegate that passes this to my windows form.
This all works but maybe there is a better way of doing this ??
Using a manual event, you can directly subscribe handlers to the control which fires the events, without the intermediate containers ever having to forward them.
My parent usercontrol is nothing else than a container (FlowLayoutPanel) for my child usercontrols.
When my app starts, it reads a database and creates child usercontrols and places it on the parent usercontrol. This includes creating the event handler coming from each child usercontrol.
Any advise would be appreciated.
Thanks
Amien.
Cape Town
www.tlabs.ac.za
Yes, that make sense now that I have played around with delegates/events a bit.
The other concern was that I wrote the event handling code inside the usercontrol. If I create the eventhandlers in my form, my form becomes too messy with all the event handlers.
Therefore I'm using a delegate in the usercontrol to pass data via a custom eventArgs class, to any form that wants to subscribe to this delegate.
But I'm very new to C# and are grateful for any help. I'm also looking at the MVC pattern suggested by Morten and it seems to fit our needs.
Thanks
Amien
.
- References:
- Cascading delegates
- From: Amien Crombie
- Re: Cascading delegates
- From: Ben Voigt [C++ MVP]
- Cascading delegates
- Prev by Date: Re: How fast is linq?
- Next by Date: Re: Incrementally saving a DataTable
- Previous by thread: Re: Cascading delegates
- Next by thread: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine
- Index(es):
Relevant Pages
|