Ajouter des écouteurs à un bouton

Author:

Ajouter,des,écouteurs,à,un,bouton
{filelink=14648}

using System;
using System.Windows.Forms;

public class EvenementBouton : Form
{

  public static void Main()
  {
    Application.Run(new EvenementBouton());
  }

  void btn_onclick(object source, EventArgs e)
  {
    Text = "Source: " + source.ToString() + " - Event: " + e.ToString();
  }

  void btn_onclick2(object source, EventArgs e)
  {
    MessageBox.Show("Source: "+source.ToString() + "nEvénement:" + e.ToString());
  }

  public EvenementBouton()
  {
    Text = "Evénement bouton";

    Button btn = new Button();
    btn.Text = "Cliquee ici";
    this.Controls.Add(btn);

    btn.Click += new EventHandler(btn_onclick);
    btn.Click += new EventHandler(btn_onclick2);
  }

}

Leave a Reply

Your email address will not be published. Required fields are marked *