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.
How do I convert type string to System.Windows.Form.TextBox?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Lalit MRank #1,186 · 1.5K reputationPosted Mar 22, 2010, 12:11 AM EDT
http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_2.0/Q_23847736.html
http://www.infernodevelopment.com/creating-c-average-calculator
http://msdn.microsoft.com/en-us/library/system.windows.forms.binding.aspx
Sam HobbsRank #107 · 20.5K reputationPosted Mar 22, 2010, 5:33 PM EDT
Note that the code is putting the textboxes in an array, and you can later use the array to get the values from the textboxes.