Eccoti il codice, spero sia tutto chiaro!ciao
Ricorda che button1 è il bottone per aggiungere, textbox1 contiene la X e textbox2 la Y (per posizionare il nuovo bottone), textbox3 contiene il testo del bottone.
Nella routine btn_Click inserisci il codice che deve essere eseguito con la pressione del bottone, riferisciti al bottone usando currentButton.Se hai problemi scrivimi.ciao
private void button1_Click(object sender, EventArgs e)
{
counter += 1;
Button myButton = new Button();
myButton.Name = "Button " + counter;
myButton.Text = textBox3.Text; //QUESTO è IL TEXTBOX CHE CONTERRA' IL TESTO
int x = Convert.ToInt32(textBox1.Text);//QUESTO è IL TEXTBOX CHE CONTERRA' LA X
int y = Convert.ToInt32(textBox2.Text);//QUESTO è IL TEXTBOX CHE CONTERRA' LA Y
myButton.Location = new Point(x, y);
myButton.Click += new System.EventHandler(this.btn_Click);//AGGIUNGE L'EVENTO CLICK
this.Controls.Add(myButton);
}
private void btn_Click(object sender, System.EventArgs e)
{
Button currentButton = (Button)sender;
//CODICE CHE VUOI
}
Stefano Passatordi
http://blogs.dotnethell.it/stem/