Shruti Rao

Shruti Rao

  • NA
  • 9
  • 0

How do I convert type string to System.Windows.Form.TextBox?

Mar 22 2010 2:51 AM

I am creating textboxes dynamically. So  I want a unique (Name) for every textbox I create, as I want to save the contents of every textbox in a file. 
for (int p = 1; p <= 4; p++)
{
string str = "txt" + b + a;     
//How so I convert this into textBox form???
TextBox txt = (TextBox)str;        //ERROR

a++;
txt =
new TextBox();
panel1.Controls.Add(txt);
Please suggest an effective code, Thank you in advance.

Answers (2)