Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to load other forms in a windows form ?

How to load other forms in a windows form ?

Scheduled Pinned Locked Moved Visual Basic
tutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kaiwnyt
    wrote on last edited by
    #1

    :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

    D Y 2 Replies Last reply
    0
    • K 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

      D Offline
      D Offline
      darkelv
      wrote on last edited by
      #2

      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(); }

      K 1 Reply Last reply
      0
      • K 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

        Y Offline
        Y Offline
        Yona Low
        wrote on last edited by
        #3

        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()

        K 1 Reply Last reply
        0
        • D darkelv

          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(); }

          K Offline
          K Offline
          kaiwnyt
          wrote on last edited by
          #4

          :)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

          1 Reply Last reply
          0
          • Y Yona Low

            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()

            K Offline
            K Offline
            kaiwnyt
            wrote on last edited by
            #5

            Thanks:)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups