How to load other forms in a windows form ?
-
:confused:Hi, I created a panel named "panel1" in a main form, and I tried to add one of child forms named "childForm1" to the panel by: " panel1.controls.add(childForm1) " but errors occured: "Top-level control cannot be added to a control." Can I load other forms in a windows form ? , and how ? Thank you very much kaiwnyt
-
:confused:Hi, I created a panel named "panel1" in a main form, and I tried to add one of child forms named "childForm1" to the panel by: " panel1.controls.add(childForm1) " but errors occured: "Top-level control cannot be added to a control." Can I load other forms in a windows form ? , and how ? Thank you very much kaiwnyt
It's in C# so you got to convert to VB. form is your form to be put in panel. if(form != null) { form.ControlBox = false; form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; form.Dock = DockStyle.Fill; form.MaximizeBox = false; form.MinimizeBox = false; form.TopLevel = false; panelTop.Controls.Add(form); form.Show(); form.BringToFront(); } else { panelTop.Controls.Clear(); }
-
:confused:Hi, I created a panel named "panel1" in a main form, and I tried to add one of child forms named "childForm1" to the panel by: " panel1.controls.add(childForm1) " but errors occured: "Top-level control cannot be added to a control." Can I load other forms in a windows form ? , and how ? Thank you very much kaiwnyt
-
It's in C# so you got to convert to VB. form is your form to be put in panel. if(form != null) { form.ControlBox = false; form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; form.Dock = DockStyle.Fill; form.MaximizeBox = false; form.MinimizeBox = false; form.TopLevel = false; panelTop.Controls.Add(form); form.Show(); form.BringToFront(); } else { panelTop.Controls.Clear(); }
:)Thanks DarkElv and Yone Low very much ! Main Form: Mainform Child Form: Form1 Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Form1.ControlBox = False Form1.FormBorderStyle = Windows.Forms.FormBorderStyle.None Form1.Dock = DockStyle.Fill Form1.MaximizeBox = False Form1.MinimizeBox = False Form1.TopLevel = False Panel1.Controls.Add(Form1) Form1.Show() Form1.BringToFront() End Sub kaiwnyt
-
Yes you can! for some reason Microsoft decided not to include the property in the designer, but it does indeed exist. see the code below. Dim frm2 As New Form2 frm2.TopLevel = False Panel1.Controls.Add(frm2) frm2.Show()