Por favor, o Regístrate para crear mensajes y debates.

Como crear un TextBox en tiempo de ejecución

 

Public Class Form2

Dim Contador As Integer = 1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim newTB As New TextBox
newTB.Name = "tbNew" & Contador

Me.Controls.Add(newTB)
newTB.Width = 200
newTB.Multiline = True
newTB.Height = 100

Panel1.Controls.Add(newTB)

Contador += 1

CambiarPosicion()
End Sub

Public Sub CambiarPosicion()
Dim Posicion As Single = 0
For Each Txt As Control In Panel1.Controls
If TypeOf Txt Is TextBox Then
Txt.Top = Posicion
Txt.Width = Panel1.Width
Txt.Height = Txt.Width * 0.6

Posicion = Txt.Top + Txt.Height

End If
Next

End Sub
End Class