Hi

I want to create text box array at desing time.It means i want to create text box like Text box1[1],TextBox[2],TextBox[3].How do u create it in desing time in C#.

Thanks
Tank50

This keeps to be a recurring question. Try the search function on this site first before posting. I tried to search for array, textbox, sudoku in the search string, the first hit was : http://www.daniweb.com/forums/thread180533.html

Hi

I want to create text box array at desing time.It means i want to create text box like Text box1[1],TextBox[2],TextBox[3]. How do u create it in desing time in C#.
Thanks
Tank50

You may create an array of TextBox at runtime (dynamically).

.....
  ....
  TextBox []t=new TextBox[5];  // Array of Five TextBox object variables.
   // Create an instance of each TextBox
   for(int i=0;i<t.Length;i++) {
       t[i]=new TextBox();
       ..... 
   }
  .....
  .....

May I ask why there is a need to add

t[i] = new TextBox();

when there is already a declaration

TextBox []t=new TextBox[5];

?

Thanks.

TextBox[] t = new TextBox[5]

The declaration above is to make the array itself, and;

t[i] = new TextBox();

This one is for creating instances of each members in the array. Actually, the explanations are included in the Syntax made by the poster above you. Just gotta pay a little more attention. :P

How to do the data binding for the text box?

Yes you are right.
Sorry about it. Thans for the explanation :)

TextBox[] t = new TextBox[5]

The declaration above is to make the array itself, and;

t[i] = new TextBox();

This one is for creating instances of each members in the array. Actually, the explanations are included in the Syntax made by the poster above you. Just gotta pay a little more attention. :P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.