container?

hi everyone,

this is my first post and I just downloaded VB2005 Express less than a week ago. I have experience in html,css, and php but i`m new to this. my question is, Im workiing on a program that, when started, opens maximized and contains a splitcontainer. At this time I have the settings set up so that Panel1 takes up 100% of the window (settings will be changed when other settings are set by the user). I also have other windows that open, Form2 and Form3 that I would like to open and load into Panel1. I did a search and was unable to find this answer, anyone have any ideas

Thanks!

Michael



Answer this question

container?

  • Ömer KAYA

    Hi,
    At first, the top-level form cann't contained by any control, so, we set TopLevel property to false.
    For Panel1, do you want to create it using Designer or at run-time
    To add it using Designer, Toolbox => Containers => Panel.
    To add it at run-time :
    Dim Panel1 As New System.Windows.Forms.Panel 'Declare Panel1
    'Set Panel1 properties, such as :
    '=============================
    Panel1.Location = New System.Drawing.Point(10, 10)
    Panel1.Size = New System.Drawing.Size(300, 300)
    Panel1.BackColor = Color.Red
    '=============================
    Me.Controls.Add(Panel1) 'Show Panel1
    Then to show Form2 :
    Dim TmpFrm2 As New Form2
    TmpFrm2.TopLevel = False
    TmpFrm2.Parent = Panel1
    TmpFrm2.Show()
    Hope this helps.


  • phoy

    At first, welcome to MSDN forums
    To show Form2 in Panel1, use this method :
    Dim TmpFrm2 As New Form2
    TmpFrm2.TopLevel = False
    TmpFrm2.Parent = Panel1
    TmpFrm2.Show()
    Hope this helps you


  • colodrmn

    Thank you! :) that worked!
  • binglehopper

    hi,

    thank you for the quick responce. unfortunetly that didnt work for me. I commented out the attempt I was making and I pasted your code in but I was getting "panel1 not defined" errors. Also, when I used your code Form2 wouldnt show up on screen. Here is what I changed the code to, but still didnt work:

    Dim Panel1 As Object 'to remove "undefined" errors
    Dim TmpFrm2 As New Form2
    TmpFrm2.TopLevel = True 'to make it show up on screen
    TmpFrm2.Parent = Panel1
    TmpFrm2.Show()

  • container?