Live Chat Icon For mobile
Live Chat Icon

How do you implement TopLevel Controls

Platform: WinForms| Category: Controls

TopLevel controls (like Form) cannot be added into Controls list using Controls.Add(). For example, if you are trying to add a form into a Panel’s control list, it will lead you to an exception ‘Top-level control cannot be added to a control’. To avoid this exception, you need to set the form’s TopLevel property to false.


Form form2 = new Form();
form2.TopLevel = false;
this.panel1.Controls.Add(form2);

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.