Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1540
Add a Form into a UltraPanel
posted

Hello,

I want to add a form1 into a panel which is on form2.

private void Form2_Load(object sender, EventArgs e)
{

form1 = new Form1();
form1.Dock = DockStyle.Fill;
this.ultraPanel2.Controls.Add(form1);~

}

But this doesn't work. Am I doing something wrong?

Thank you.

Best regards,

Maria

Parents
No Data
Reply
  • 5118
    posted

    You also need to set TopLevel to false on form1 so it can be added as a child control. 

    The UltraPanel should add child controls through UltraPanel.ClientArea.Controls instead of directly off the Controls collection property of the UltraPanel.

    Also don't forget to call show on the form instance after you add it to the collection. 

    In general it is better to use UserControls for this layout, but if you must use Forms you can achieve the desired results with the above modifications.

Children