Create textfield on the fly

im trying to make it so if a button is selected that it creates a new textfield . i need this for if the user needs another space for a new item. ex. adding each student from classrooms. (not every class has the same amount of students and i dont want the form to be huge. can someone show me an example? Thankyou

Target?

still not sure what you mean.

Your app is desktop, web or iOS?

Assuming desktop…
Drag a single textField to you window. Make it the basis of a new control set (see the docs). Let’s say you named this textfield myTxt. It will be index 0 of your control set. Now to create some new members of this set in code…
Dim t as textfield

For I As Integer = 1 to 5. // to Create 5 new text fields t = new myTxt t.top = 100 t.left = 20 // and so on Next

HTH

A ListBox would be a better control for this usage.

@Tim Parnell I would agree but not for what im using it for. what im working on but it has to be a textfield. thank you tho

[quote=163558:@Roger Clary]Dim t as textfield

For I As Integer = 1 to 5. // to Create 5 new text fields
t = new myTxt
t.top = 100
t.left = 20
// and so on
Next[/quote]
This works for creating an Item on the fly but keeps stacking on top of each other. How can i get it to find the last textfield created and go right below it ? The For I As Integer = 1 to 5. isn’t even being used as to my knowledge .?

Change

t.top=100
to
t.top=100 + ((t.Height + 14) * I)

[quote=168325:@Tim Jones]Change

t.top=100
to
t.top=100 + ((t.Height + 14) * I)[/quote]
Using this creates all 5 at once . i need it so if the user needs to have another size they can create a new field by clicking the Button. not create all at once.

Keep track of the position of the last one you created and use that to position the new one. Add a property to the window,

LastTop as Integer and in the button use

t = new MyTxt
t.Top = LastTop+ t.Height+ 14
LastTop = t.Top

[quote=168344:@Tim Hare]Keep track of the position of the last one you created and use that to position the new one. Add a property to the window,

LastTop as Integer and in the button use

t = new MyTxt t.Top = LastTop+ t.Height+ 14 LastTop = t.Top [/quote]
Had to tweak it a little bit but good to go! Thank you @Tim Hare . Got one more question now. How do i call that field now . its it just my name of my Control set and then (1) so it would be like TextField23(1).text as the newly created TextField ?

That’s right.

AWESOME!!! thank you so much again @Tim Hare

Thanks again,
Travis McBride