Home > other >  Form inside another form without using MDI
Form inside another form without using MDI

Time:03-26

Goal: Make Form3 (red) inside Form2 (blue) which's MDI child of Form1 (yellow)

Form3 have it's own code and own design, I need it to be part Form2 in some situations, not always.

I could make Form3 (red) MDI child of Form2 (blue), but the problem is that Form2 (blue) is already MDI child of Form1 (yellow).

How can I solve this problem?

enter image description here

CodePudding user response:

Each Control has a property Controls, to which you can Add a Control, but if you try to do that with a Form, you get the exception

Top-level control cannot be added to a control.

even though Form : Control

But you could just fill a control with a Panel with all the Form's controls in it, and take that Panel and add it to another Control.

' In Form1, Panel1 is defined, you will put the other panel in here
' In Form2, Panel1 is defined, this is the other panel
Me.Panel1.Controls.Add((New Form2).Panel1)
  • Related