Making a form a child of a control

  • Thread starter Thread starter Tim A.
  • Start date Start date
T

Tim A.

In Delphi it's possible to make a form appear inside a panel control as a
child subform by setting the form's Parent property to the instance of the
control. When I try to do the same in .NET I get the error "Cannot make a
top-level control a child of another control". It would really be a huge
disappointment to find out that Windows Forms doesn't allow nesting of forms
inside panel controls, so I hope I'm just not doing it right.

Any suggestions?
 
Never mind, just found the answer:

myForm.TopLevel = false;
myForm.FormBorderStyle = FormBorderStyle.None;
panel1.Controls.Add( myForm ); // or myForm.Parent = panel1;

Funny that setting TopLevel to false at design time didn't seem to do the
trick. It HAD to be set at runtime for the Parent assignment to work!
 
Does anybody knows how to close a, TopLevel=False and child from another
control, form.

I open a from using the lines below but I cannot close it after.

Thanks.
 
* "Oriol said:
Does anybody knows how to close a, TopLevel=False and child from another
control, form.

I open a from using the lines below but I cannot close it after.

Remove it from the container's 'Controls' collection and call its
'Close' method.
 

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

Back
Top