Cant create 2nd textbox
- by okinaw55
Having problems with this code and cant figure out why. It works fine the first time through but crashes with a Parameter is not Valid error the 2nd time on this line.
Dim tbx As TextBox = New Windows.Forms.TextBox
Any help is appreciated.
Dim tbx As TextBox = New Windows.Forms.TextBox
tbx.Name = tbxName
tbx.Size = New System.Drawing.Size(55, 12)
tbx.BorderStyle = BorderStyle.None
tbx.TextAlign = HorizontalAlignment.Center
Using f As Font = tbx.Font
tbx.Font = New Font(f.FontFamily, 8, FontStyle.Bold)
End Using
tbx.Location = New System.Drawing.Point(xCords, 44)
Select Case tbx.Name
Case "tbxBulk01" : tbx.Text = Bulk01Label
Case "tbxBulk02" : tbx.Text = Bulk02Label
End Select
Me.Controls.Add(tbx)
Stack trace as follows.
at System.Drawing.Font.GetHeight(Graphics graphics)
at System.Drawing.Font.GetHeight()
at System.Drawing.Font.get_Height()
at System.Windows.Forms.Control.get_FontHeight()
at System.Windows.Forms.TextBoxBase.get_PreferredHeight()
at System.Windows.Forms.TextBoxBase.get_DefaultSize()
at System.Windows.Forms.Control..ctor(Boolean autoInstallSyncContext)
at System.Windows.Forms.TextBoxBase..ctor()
at System.Windows.Forms.TextBox..ctor()