I need to dynamically create textbox.
This is my code, but with this I create only one textbox:
Public Sub CreateTextBox()
Dim I As Integer
Dim niz As Array
For I = 1 To 5
Dim myTextBox = New TextBox
myTextBox.Text = "Control Number:" & I
Me.Controls.Add(myTextBox)
Next
End Sub
So how i can dynamically create textbox?
Thanks!
This code is actually creating 5 instances of
TextBoxand adding them to the current form. The problem is that you are adding them one on top of another. You need to use a layout mechanism to display them correctly.For example this code will add them to a
FlowLayoutPanelin a top down fashion.