Dynamic Textbox

 

TextBox[] textbox1;
Label[] label;
int i;

int cnt = 1;
int x = 110;
int y = 50,z=10;
Button btn = new Button();
textbox1 = new TextBox[i1];
label = new Label[i1];
for (i = 0; i < i1; i++)
{
textbox1[i] = new TextBox();
label[i] = new Label();
label[i].Location = new Point(z,y);
label[i].Name = “Serial No ” + cnt.ToString();
label[i].Size = new System.Drawing.Size(173, 20);
label[i].Text = “Serial No ” + cnt.ToString();
label[i].Font = new Font(“Microsoft Sans Serif”, 10,FontStyle.Bold);
label[i].Visible = true;

textbox1[i].Location = new System.Drawing.Point(x, y);
textbox1[i].Name = “textbox” + cnt.ToString();
textbox1[i].Size = new System.Drawing.Size(173, 20);
textbox1[i].Font = new Font(“Microsoft Sans Serif”, 10, FontStyle.Bold);
textbox1[i].TabIndex = cnt;
textbox1[i].Visible = true;
cnt++;
y += 50;
panel1.Controls.Add(textbox1[i]);
panel1.Controls.Add(label[i]);

}
btn.Location = new Point(x, y);
btn.Text = “Submit”;
btn.Size = new System.Drawing.Size(143, 30);
btn.Font = new Font(“Microsoft Sans Serif”, 10, FontStyle.Bold);
btn.Click += new System.EventHandler(this.btn_Click);
btn.FlatStyle = FlatStyle.Flat;
btn.BackColor = Color.SandyBrown;
panel1.Controls.Add(btn);
}

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: