There are many ways you can get the user controls to access the business
layer. It's up to you to see what fits best your needs.
1. From the host form, you can set a reference to the business object to
each user control.
2. The host form can hold the business object and implement an interface to
return that business object. The user control can then get the host's
business object from the common interface.
ex: public interface IBusinessHost { public BusinessBase
tBusiness(); }
3. Each user control could initiate it's own Business object.
I have a few very complex forms that I divided into user controls. In the
host form's load event, I call a method called Bind on each user control. As
a parameter, I pass necessary references such as the business object.
Does the control access the business layer directly or does the control
get access via the hosting form?
Would it be usefull at all to get the user control communicate only with the
host form? If a user control have to work with data, it should communicate
with the object managing data; that is, the business object.
Etienne
"Dan" <Da*@discussion s.microsoft.com > wrote in message
news:F9******** *************** ***********@mic rosoft.com... All,
I have a windows form application. The form will host various user
controls
that will implement an interface so that was new controls can be added
later
without recompiling the hosting program.
The various controls will be displaying data that is stored in a SQL
database.
My question is what is the prefered way of having the controls access the
business layer that will in turn access the data layer? Does the control
access the business layer directly or does the control get access via the
hosting form? Any insight or reasons as to why one way is prefered would
be
great.
Thanks for the help!
Dan