Hi Amien,
Nothing wrong with this approach. However, I suspect the actual data flow
isn't related to the actual user controls rather than the objects they
display. You might consider moving the event flow to the object level.
For instance, if the parent Control displays a parent object and the
UserControl displays a child object, the parent object may subscribe to
events the child objects may throw and the parent control will in turn
display the result on the parent control through databinding. Also, the part
that does the actual update between the object is a separate object called a
Controller or a Presenter.
If you want to read up on this, there is a Model-View-Presenter pattern as
well as a Model-View-Controller pattern. MVC is more or less the same as MVP
although somewhat stricter in separating the View from the Model.
--
Happy Coding!
Morten Wennevik [C# MVP]
"Amien Crombie" wrote:
> Hi
>
> 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 ??
> 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
>
>
>