View Single Post
 
Old 06-14-2014, 03:05 PM
Rabastan Rabastan is offline
Newcomer
 
Join Date: Aug 2012
Posts: 3
Default Panel inside panel not working

I am attempting to create multiple panels inside a main panel that will open (or become visible) as a "continue" button is pressed on each panel. Its just a simple program I am creating to try and learn VB. Here is what I have so far.

Code:
Public Class frmMain

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       
        Dim pnlMain As New Panel()
        pnlMain.Location = New System.Drawing.Point(12, 140)
        pnlMain.Name = "pnlMain"
        pnlMain.Size = New System.Drawing.Size(650, 580)
        pnlMain.BackColor = Color.White
        pnlMain.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

        Dim pnlStep1 As New Panel()
        pnlStep1.Location = New System.Drawing.Point(3, 3)
        pnlStep1.Name = "pnlTab1"
        pnlStep1.Size = New System.Drawing.Size(644, 100)
        pnlStep1.BackColor = Color.WhiteSmoke
        pnlStep1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

        Me.Controls.Add(pnlMain)
        Me.pnlMain.Controls.Add(pnlStep1)


        Dim pnlSub As New Panel()
        pnlSub.Location = New System.Drawing.Point(668, 140)
        pnlSub.Name = "pnlMain"
        pnlSub.Size = New System.Drawing.Size(328, 580)
        pnlSub.BackColor = Color.White
        pnlSub.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

        Me.Controls.Add(pnlSub)
    End Sub

End Class
I am creating two panels a main one and a smaller one to the right (to be used later). I have placed another panel within the main panel for "Step 1".

The problem I am having is at "Me.pnlMain.Controls.Add(pnlStep1)" 'pnlMain" is not a member of Just_Learning.frmMain".

What am I doing wrong?

Rab
Reply With Quote