Buenas compañero,
Espero que te ayude esto:
Código C:
Ver originalpublic partial class Form1 : Form
{
private int iClick;
public Form1()
{
InitializeComponent();
iClick = 0;
}
private void Form1_Load(object sender, EventArgs e)
{
//Números del 1 al 25.
for(int iCont = 1; iCont <= 25; iCont++)
{
Button btnNumero = new Button();
btnNumero.Name = "btnNumero" + iCont.ToString("00");
btnNumero.Size = new Size(28, 28);
btnNumero.TabIndex = iCont;
btnNumero.Text = iCont.ToString("00");
btnNumero.Click += new EventHandler(EventAñadirNumero);
btnNumero.UseVisualStyleBackColor = true;
this.pnlBotones.Controls.Add(btnNumero);
}
}
private void EventAñadirNumero(object sender, EventArgs e)
{
if (iClick != 14) {
Button btnNumero = (Button)sender;
this.txtNumeros.Text += " " + btnNumero.Text;
btnNumero.Enabled = false;
iClick++;
}else{
MessageBox.Show("Ya has elegido 14 números.");
}
}
}
Sino entiendes cualquier cosa... Pregunta o San Google te puede ayudar :)
Resultado:
Un saludo!!!