How to get values of dynamically created Textboxes

Mar 8 2007 8:42 AM
Hi Forum,

I am newbie and trying to windows application where I got two forms.
From one form I get he value from user that how many textboxes he wants to created. Then accordingly the those textboxes are created on form 2 by writing a code in form1 like this..

Form2 frm = new Form2();

frm._textBoxI = _textBoxInputs;

frm._textBoxO = _textBoxOutputs;

frm._textBoxN = _textBoxSysEl;

int top = 25;

int ii, io, newtop;

for (ii = 0; ii < noInputs; ii++)

{

Label labeli = new Label();

TextBox textBoxi = new TextBox();

frm.Controls.Add(labeli);

frm.Controls.Add(textBoxi);

labeli.Top = top;

labeli.Left = 20;

labeli.Text = "Name Of " + Convert.ToString(ii + 1) + " Input :";

textBoxi.Top = top;

textBoxi.Left = labeli.Width + 20;

textBoxi.Name = "textBoxi" + Convert.ToString(ii);

//delPassData del = new delPassData(frm.funData);

//del(textBoxi);

top = top + 30;

}

frm.Show();

The form2 is created by with all the textboxes on it.
Now I want to use the text entered in these textboxes, so that on button click i can do some calculations. but i am unable to get the names of those textboxes outside the for loop.

Can anybody suggest anything Plz I am struck-up with it.
Tried all the methods of passing values from one form to another, and also creating the textbox on form2 itself but not able to collect the values entered in the textboxes(I am able to get the blank values while they are getting created, but i want that user should entered the value after textboxes are created, get those values  and not the blank one)

Thanks in advance

Priya