guarda che io ho provato ,e mi attengo alle risposte
inserisco il pezzo di codice ,ma non riesco ad identificare il xbot.name che a me serve per
andare avanti
Button butt = (Button)sender; <--- questo non mi da un errore ma ... come servirmene??
cioe
codice:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
Button[] xbot = new System.Windows .Forms .Button[10] ;
public Form1()
{
InitializeComponent();
lancia_bottoni();
}
public void lancia_bottoni(){
int assex = 20;
for(int giro=0;giro<10;giro++){
xbot[giro] = new Button();
xbot[giro].Click += new System.EventHandler(this.xbot_click);
xbot[giro].Location = new System.Drawing.Point (assex, 20);
xbot[giro].Text = giro.ToString() ;
xbot[giro].Name = giro.ToString();
xbot[giro].Size = new System.Drawing .Size(20, 20);
xbot[giro].Visible = true;
assex = assex + 30;
this.Controls.Add(xbot[giro]);
}
}
void xbot_click( System.Object sender,EventArgs e )
{
Button butt = (Button)sender;<---- qui penso sia gusto
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}