Button aButton = new Button();
aButton.Name = "Button"; //you also can set height width
targetPanel.Controls.Add(aButton);
Cheers.
You r right but this only creates one button dynamically
I want to create buttons as long as user wants
I am posting my code that will add a textbox and a label to the panel of the form
It only prints one textbox and and label dynamically
private void button1_Click(object sender, EventArgs e)
{
j = j + 25;// increment the position of the labael and text box
this.textbox2.Size = new System.Drawing.Size(75, 20);
this.textbox2.Location = new System.Drawing.Point(91, j);
this.textbox2.Name.Equals("textbox" + i);
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(13, j);
this.label2.Name.Equals("Enter number" + i);
this.label2.Size = new System.Drawing.Size(72, 13);
this.label2.Text = "Enter Number" + i;
this.panel1.Controls.Add(this.textbox2);
this.panel1.Controls.Add(this.label2);
i++;//increments the number of textbox an label added
}
[IMG]C:\Documents and Settings\NOUMAN\Desktop\untitled.bmp[/IMG]