How to create textbox and label controls dynamically?
Posted on 2007-03-19
I am trying to find a way to create label and textbox controls dynamically when a user hits a button through code.
The following code is giving me an error after the Dim statement.
Error: Variable ‘NewLabel; is used before it has been assigned a value. A null reference exception could result at runtime.
Dim NewLabel As Label
NewLabel.Height = 19
NewLabel.Width = 25
NewLabel.Text = "Nothing"
NewLabel.Location = New System.Drawing.Point(13, 13)
What am I missing?