Text Boxes

  • Thread starter Thread starter Shane Mergy
  • Start date Start date
S

Shane Mergy

heres my situation i have a class (to make them available
to all forms) that has
textBox txtBox1 = new textBox();
textBox txtBox2 = new textBox();
and so on however this is a slow way of doing it can and
I know there is a better way to dinamicly create text
boxes however i cannot figure it out and need help can
someone tell me how to do create text boxes with a for
loop.
 
I think you could use a collection type.

Then you can create the text boxes and add them to the
collection.

ex.: myCollection.add(new TextBox());

Collections types also have important methods that can be
useful for you:

myCollection.Contains();
myCollection.Remove();
 
no no i know there is a way to do it i have come across
it in the help but cant seem to find it anymore i want to
create them with a loop.
 
I'd say Eduardo's response was correct. You just need to stick it in a loop.

I assume you know how many textboxes you want to create and I assume you are
not hoping to get sensible TextBox names auto-generatted in the loop.

Edwardo's myCollection will contain all the created texboxes. I sometimes
use an ArrayList for the same purpose.

John.
 
Back
Top