design question about user controls...

alanchinese

Regular
Joined
Jan 12, 2005
Messages
62
i have two projects, ProjControls and ProjForms
ProjControls includes CtrlAddress, which is a group of controls CtrlText (includes the TextBox control, for street, city, and zipcode) and CtrlOptions (includes ComboBox control, for state codes).
ProjForms includes FormCustomer, that uses CtrlAddress inside the form. that's why i need to include ProjControls' dll for ProjForms
ProjForms also includes FormZipcode, and FormCity, etc. which shares similar UI of the FormCustomer.

what i want to do is, inside the CtrlAddress, i want to have a button so that by clicking it users can access information for certain zipcode or city.
now i have the problem: I cannot include the reference of ProjForms into ProjControls....

i want to see how you handle this issue? should i combine ProjControls and ProjForms together (tha's not what i want to do, because there are reasons for me to group them seperately)
thankx.
 
IngisKahn said:
Provided you're dealing with class libraries referencing other projects shouldn't be a problem.

no, it complains i cannot link ProjControls to the forms because it will create a loop -- ProjForms already ref ProjControls.
 
Even if the devstudio wouldnt complain you still wouldnt want a circular reference:
For instance you have dll A and dll B. Both try to refer to each other. Now the compiler needs B to compile A. But to compile A it would need to have a compiled version of B. It can't create either because each needs the other first.

Why do you try to implement the lookup funcitonality in the control. Why not implement it in the forms. You can add an event to the Control that is triggered when the user clicks on the search button: ZipCodeInformationRequested (but give it a better name ;) ). This event can then be handled by the form and it can do the lookup it knows how to do.
This trick will also keep your control lightweight and maybe even easier to re-use ;).
 
Back
Top