Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Form inside control

Hello everybody!

I'm making an options dialog with a set of options categories on a listview to the left. On the right I want to place each set of parameter controls corresponding to the options category chosen.


Could I have a picturebox-like thing on the right and just insert a form in it? In this way I could make one form for each set of parameters and just do a:

picturebox_or_what_ever.form = currentChosenForm


Is this possible somehow?

Goba
Monday, November 15, 2004

You might try doing it with a panel and user controls instead:

For your right hand side part - setup a panel.  Then when a user clicks on one of the ListItems just do:

panel.Controls.Clear();
panel.Controls.Add(new MyCustomControl());

smallbiz
Monday, November 15, 2004

The thing is that instead of adding controls, I would like to add a Form with controls.

Goba
Tuesday, November 16, 2004

This used to be possible in the good old days of VB6. You could call an API to set the parent of a window (form) to another form, or some control on another form.

I don't know if it is still possible with WinForms.

Have you considered using MDI child forms, with the MDI Parent being the surrounding Options Form ?

These are all hacks really. You should really use UserControls, as others have suggested.

Nemesis [µISV]
Tuesday, November 16, 2004

"The thing is that instead of adding controls, I would like to add a Form with controls."

Any particular reason why you want to use a form instead of a control?

smallbiz
Tuesday, November 16, 2004

Yeah, have a look at usercontrols. Basically, forms without the header bar that you can drop onto forms.

Steve Cooper
Tuesday, November 23, 2004

"The thing is that instead of adding controls, I would like to add a Form with controls."

Basically the same as suggested above, but with small variation:

How about putting ListBox on the left and for each Configuration section put a Panel on the right. Set ListBox's Dock to Left and each panel's Dock to Fill (so that Panels are kind of stacked) and put all the controls corresponding to certain Configuration section to a specific panel. Then when user selects Configuration section from the ListBox on the left, just bring the relevant panel on top with BringToFront method (e.g. ColorsPanel.BringToFront()).

Razor
Thursday, November 25, 2004

*  Recent Topics

*  Fog Creek Home