Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   .NET Interface and Graphics (http://www.xtremevbtalk.com/-net-interface-and-graphics/)
-   -   Panel inside panel not working (http://www.xtremevbtalk.com/-net-interface-and-graphics/327109-panel-inside-panel.html)

Rabastan 06-14-2014 02:05 PM

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.


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


        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

    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?


PlausiblyDamp 06-15-2014 07:41 AM

When you prefix a variable with Me you are telling VB to refer to a variable declared at the class level i.e. outside of an individual method. pnlMain is defined within the Load event though and not at the class level.

If you remove the Me from the front of that line it should work.

All times are GMT -6. The time now is 11:44 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.