title: Simpler way to make multiple panels with controls
body: <p>I am working on my first VB program. I have a form with a panel. I side that panel are a series of panels that open when a continue button is Clicked.</p>
  
  <p>Like so:</p>
  
  <pre><code>Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)  Handles MyBase.Load
  
      'Main Panel Layout'
      pnlMain.Location = New System.Drawing.Point(5, 150)
      pnlMain.Name = "pnlMain"
      pnlMain.Size = New System.Drawing.Size(600, 525)
      pnlMain.BackColor = Color.White
      pnlMain.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
      pnlMain.AutoScroll = True
  
      'Sub Panel Layout'
      pnlSub.Location = New System.Drawing.Point(610, 150)
      pnlSub.Name = "pnlSub"
      pnlSub.Size = New System.Drawing.Size(648, 525)
      pnlSub.BackColor = Color.Gainsboro
      pnlSub.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
  
      'Layout Step 1 Panel'
      pnlStep_1.Location = New System.Drawing.Point(2, 2)
      pnlStep_1.Name = "pnlStep_1"
      pnlStep_1.Size = New System.Drawing.Size(579, 100)
      pnlStep_1.BackColor = Color.Gainsboro
      pnlStep_1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
  
      'Layout Step 1 Label'
      lblStep_1.Location = New Point(230, 38)
      lblStep_1.Text = "Step l"
      lblStep_1.Size = New Size(137, 24)
      lblStep_1.Font = New Font(lblStep_1.Font.FontFamily, 14, FontStyle.Bold)
  
      'Layout Step 1 Button"
      btnStep_1_Cont.Location = New Point(502, 73)
      btnStep_1_Cont.Text = "Continue"
      btnStep_1_Cont.Size = New Size(75, 25)
      btnStep_1_Cont.BackColor = Color.WhiteSmoke
  
      'Create Instane of Base Panels'
      Me.Controls.Add(pnlMain)
      Me.Controls.Add(pnlSub)
  
      'Create Instances of Step 1 Controls'
      pnlMain.Controls.Add(pnlStep_1)
      pnlStep_1.Controls.Add(lblStep_1)
      pnlStep_1.Controls.Add(btnStep_1_Cont)
  
      'Create Button Events for Step 1'
      AddHandler btnStep_1_Cont.Click, AddressOf btnStep_1_Cont_Click
  
  End Sub
  Private Sub btnStep_1_Cont_Click(ByVal sender As Object, ByVal e As EventArgs)
  
  'Layout Step 2 Panel'
  pnlStep_2.Location = New System.Drawing.Point(2, 27)
  pnlStep_2.Name = "pnlStep_2"
  pnlStep_2.Size = New System.Drawing.Size(579, 100)
  pnlStep_2.BackColor = Color.Gainsboro
  pnlStep_2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
  
  'Layout Step 2 Label'
  lblStep_2.Location = New Point(21, 38)
  lblStep_2.Text = "Step 2"
  lblStep_2.Size = New Size(554, 24)
  lblStep_2.Font = New Font(lblStep_2.Font.FontFamily, 14, FontStyle.Bold)
  
  'Layout Step 2 Button"
  btnStep_2_Cont.Location = New Point(502, 73)
  btnStep_2_Cont.Text = "Continue"
  btnStep_2_Cont.Size = New Size(75, 25)
  btnStep_2_Cont.BackColor = Color.WhiteSmoke
  
  'Create Instances of Step 2 Controls'
  pnlMain.Controls.Add(pnlStep_2)
  If pnlMain.Contains(pnlStep_1) Then
      pnlStep_2.BringToFront()
  End If
  pnlStep_2.Controls.Add(lblStep_2)
  pnlStep_2.Controls.Add(btnStep_2_Cont)
  
  'Create Button Events for Step 2'
  AddHandler btnStep_2_Cont.Click, AddressOf btnStep_2_Cont_Click
  </code></pre>
  
  <p>End Sub</p>
  
  <p>And so on...</p>
  
  <p>This will have over 50 steps in it. Which will get rather messy and repetitive after awhile. Is there a way to create a class create the panels and place each one a certain amount of px from the top of the last one? and just call that class and have them come up.</p>
  
  <p>Same for the rest of the controls could I create a class for them and just enter the parameters.</p>
  
  <p>With the Labels and the buttons, some may have two or three buttons and up to four labels. </p>
  
  <p>Thanx in advance </p>
  
  <p>Rab</p>