I hope this code helps you. Just paste this code into the project code editor and run the program. The comments should help explain what I've done. I think it accomplishes what you'd like, but you'll definitly want to modify it to your liking (ie. controls sizes and all that stuff). Hopefully you can work with it though.
Public Class Form1
'Location of the next Panel
Dim NextRecLoc As New Point(10, 10)
'The "active" textbox (TextBox left of the button)
Dim CurrentTextBox As TextBox = Nothing
Dim WithEvents btnPanelButton As New Button
'Adds a panel with textbox below the last one
Private Sub NextRecord()
'Distance between panels
Dim SPACER As Integer = 10
'New panel object
Dim newPanel As New Panel
'Set a border style so we can see the panel
newPanel.BorderStyle = BorderStyle.FixedSingle
'Set the panels size
newPanel.Size = New Size(300, 40)
'Set the location
newPanel.Location = NextRecLoc + Me.AutoScrollPosition
'New TextBox object for the panel
Dim newTextBox As New TextBox
newTextBox.Size = New Size(200, 20)
newTextBox.Location = New Point(10, 5)
'Set the current textbox to this new one
CurrentTextBox = newTextBox
'Add the new TextBox to the panel
newPanel.Controls.Add(newTextBox)
'Adjust NextRecLoc
NextRecLoc.Y += newPanel.Size.Height + SPACER
'Add the panel to the form
Me.Controls.Add(newPanel)
'Move the button to the right of newPanel
btnPanelButton.Location = New Point(newPanel.Right + 10, newPanel.Top)
End Sub
Private Sub btnPanelButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPanelButton.Click
'Do what you want with the information in the "active" textbox here
If CurrentTextBox IsNot Nothing Then
'Display the text
MsgBox(CurrentTextBox.Text)
End If
'Create a new record
NextRecord()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Turns on the forms AutoScroll
Me.AutoScroll = True
'Add the button to the form
btnPanelButton.Size = New Size(75, 25)
btnPanelButton.Text = "Submit"
Me.Controls.Add(btnPanelButton)
'Create the first record
NextRecord()
End Sub
End Class
Enter your message below
Sign in or Join us (it's free).