Tuesday, August 4, 2009

Dynamic creation of textbox using C#

Dynamix creation of 5 textbox in windows application using C#:

int x = 10;
int y = 20;
List dynamictxt = new List();
for (int i = 0; i < 5; i++)
{
TextBox txtbox = new TextBox();
txtbox.Name = "textbox" + i.ToString();
txtbox.Location = new Point(x, y * i);
dynamictxt.Add(txtbox);
this.Controls.Add(txtbox);

}