Docking a Form into a Panel

D

Daniel Jeffrey

Can anyone help me please.

I want to dock a form into a panel

Basically what I would want is a Panel that IS a MDI Container or a similar
solution.

Any suggestions?

Daniel
 
N

Nicholas Paldino [.NET/C# MVP]

Daniel,

Do you have control over the forms? If so, then I would suggest that
all of the controls on the form actually go on a panel itself, then, when
you want to dock the controls, you re-parent the panel on the form to the
panel you want to dock the form to.
 
D

Daniel Jeffrey

wont the form still show then?


I am guessing you mean something like this

SimpleForm sf = new SimpleForm();

sf.Panel.Parent = this.SomePanel;

sf.Show();

?

Dan

Nicholas Paldino said:
Daniel,

Do you have control over the forms? If so, then I would suggest that
all of the controls on the form actually go on a panel itself, then, when
you want to dock the controls, you re-parent the panel on the form to the
panel you want to dock the form to.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Daniel Jeffrey said:
Can anyone help me please.

I want to dock a form into a panel

Basically what I would want is a Panel that IS a MDI Container or a
similar solution.

Any suggestions?

Daniel
 
B

Bill Woodruff

I want to dock a form into a panel

Unless I mis-understand your goal ...

put a Panel on a Form, but a button on the Form that when you click it does
something like this :

Form newForm = new Form();
newForm.TopLevel = false;
// size the Form, set its TitleBar attributes, FormBorderStyle or whatever
panel1.Controls.Add(newForm);
newForm.Show();
newForm.Dock = DockStyle.Top;
newForm.BringToFront();

Set the AutoScroll property of Panel to 'true and each new Form will appear
at the top of all other added Forms.

You can easily write code to minimize all these windows, or maximize them,
etc, by just using foreach on the panel1.Controls property ... assuming that
all contents of your panel are Forms.

best, Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top