tags:

views:

32

answers:

1

I have sets of controls contained in individual GroupBox controls.

So say GroupBoxCommon contains Common UI Items, GroupBoxSpecific contains Specific UI items, etc.

I have a way of stacking them in a single UI (floating panel) based on the current selection in the app.

I am just wondering how I should store these sets of controls? Should I create separate forms for each inside this single assembly (that's used by the app).

Should I create them dynamically, as in:

Create GroupBoxCommon
Add Button
Add Button
...

Or should I have them in a single form but offsetted?

To me #1 seems to be the way, but there might be a better way to do this?

In the all I will do is to fetch these sets of controls and stack them in a single UI.

+3  A: 

Put each group of controls inside a UserControl. That's what they are designed for, and it will probably make your form code simpler because it will be dealing with less controls.

There is no problem defining UserControls inside a DLL, there's even a project template for it ("Windows Forms Control Library" IIRC).

Christian Hayter
Thanks, but when I define a UserControl, shouldn't it have to be a custom control, not a custom control instance?
Joan Venge
Sorry, I don't understand your question. All you need to do is create (a) a UserControl called CommonControl, which contains the CommonGroupBox, which contains the common UI items, and (b) a UserControl called SpecificControl, which contains the SpecificGroupBox, which contains the specific UI items. Repeat (b) for each different set of specific UI items.
Christian Hayter