0

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

6
Contributors
6
Replies
12
Views
7 Years
Discussion Span
Last Post by rationalise
0

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();
       ..... 
   }
  .....
  .....
0

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.

0
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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.