I'm trying to create a form with multiple labels, textboxes and buttons within a panel. The user will fill in their data and click a button that will create a new identical panel with the same labels, textboxes and buttons.
I read through the following thread in an effort to begin understanding the process:
I've attempted to try using some of the same code to do as I wish to no avail. Here is what I've written:
Public Sub frmOrderEntry2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load ' 'This creates the label "Part No." Dim lblPrtNo As Label = New Label lblPrtNo.Name = "lblPrtNo" lblPrtNo.Text = "Part Number" lblPrtNo.ForeColor = Color.White lblPrtNo.Font = New System.Drawing.Font("Sans Serif", 9) lblPrtNo.Font = New System.Drawing.Font(lblPrtNo.Font, FontStyle.Regular) lblPrtNo.Location = New Point(6, 8) lblPrtNo.Size = New Size(77, 15) lblPrtNo.TextAlign = ContentAlignment.MiddleLeft lblPrtNo.Enabled = False AddHandler lblPrtNo.TextChanged, AddressOf lblPrtNo_Textchanged Me.Controls.Add(lblPrtNo) ' 'This generates the textbox for the user to enter the Part No. Dim txbPartNo As TextBox = New TextBox txbPartNo.Name = "txbPartNo" txbPartNo.Text = "" txbPartNo.ForeColor = Color.Black txbPartNo.BackColor = Color.White txbPartNo.Font = New System.Drawing.Font("Sans Serif", 10) txbPartNo.Font = New System.Drawing.Font(txbPartNo.Font, FontStyle.Bold) txbPartNo.Location = New Point(6, 26) txbPartNo.Size = New Size(263, 22) txbPartNo.TextAlign = ContentAlignment.MiddleLeft txbPartNo.Cursor = Cursors.Hand txbPartNo.AcceptsReturn = True txbPartNo.AcceptsTab = True txbPartNo.TabIndex = 10 txbPartNo.Enabled = True AddHandler txbPartNo.TextChanged, AddressOf txbPartNo_Textchanged Me.Controls.Add(txbPartNo) Private Sub lblPrtNo_Textchanged(ByVal sender As System.Object, ByVal e As EventArgs) Dim lblPrtNo As Label = DirectCast(sender, Label) Me.Text = lblPrtNo.Name & ": " & lblPrtNo.Text lblPrtNo.Show() End Sub Private Sub txbPartNo_Textchanged(ByVal sender As System.Object, ByVal e As EventArgs) Dim txbPartNo As TextBox = DirectCast(sender, TextBox) Me.Text = txbPartNo.Name & ": " & txbPartNo.Text txbPartNo.Show() End Sub
So that I am clear, this is just one label and one textbox of a total of 11 labels, 11 textboxes and 3 buttons within the one panel that needs to be created.
When I run the above code, the form is empty. Nothing appears. What am I missing? Any suggestions as to how to fix this?
In advance, thanks for any help.
P.S. I'm using Visual Basic (Visual Studio 2010 Express)