Hi,
Try this:
private void button1_Click(object sender, EventArgs e)
{
AddDynamicTextBox(5);
}
public void AddDynamicTextBox(int numberOfTextBoxes)
{
for (int i = 0; i <= numberOfTextBoxes; ++i)
{
TextBox textBox = new TextBox();
textBox.Name = "TextBox" + i.ToString();
textBox.Text = "TextBox" + i.ToString();
textBox.Location = new Point(20, i * 20);
this.Controls.Add(textBox);
}
}
The "numberOfTextBoxes" you will defined from your input. One thing you need to be careful of is the location, if you do not give location value, the control will add each text box on top of each other so it will look like there is only one text box.
Regards
Jegan