Link to home
Start Free TrialLog in
Avatar of NCSA SCADA
NCSA SCADAFlag for United States of America

asked on

vb.net dynamically add, name, place and resize text boxes to a windows form

Hi Experts - I am trying to create a form that will add texboxes to a form.  Just to figure it out, I have created a simple form with one button and one text box.  User enters a number in the text box and it shoud create that number of textboxes. I don't know if I am going about this the wrong way, but here is what I have so far - Also is there a way to dictate the size and  position  -(by the way, I am a newbie)
Thanks
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim I As Integer
        MsgBox(txtNumber.Text)
        For I = 1 To txtNumber.Text
            Dim myTextBox = New TextBox
            myTextBox.Name = "txtDynamic" & I
            myTextBox.Text = "Control Number:" & I
            Me.Controls.Add(myTextBox)
        Next
 
 
    End Sub

Open in new window

Avatar of UnifiedIS
UnifiedIS

myTextBox.Size = new size(x,y)
myTextBox.Location.X =
myTextBox.Location.Y =
Avatar of NCSA SCADA

ASKER

Thanks for the quick response -
I must be missing somthing - I tried this
            myTextBox.Size = New Size(10, 10)
            myTextBox.Location.X = "485"
            myTextBox.Location.Y = "339"
I get this error - "Expression is a value and therefore cannot be the target of an assignment
ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That worked perfect - thanks for the additional info as well - cleared it right up