2
Answers

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

Shruti Rao

Shruti Rao

14y
5.4k
1

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)