
{filelink=14641}
using System;
using System.Drawing;
using System.Windows.Forms;
class ExempleBouton: Form
{
public static void Main()
{
Application.Run(new ExempleBouton());
}
public ExempleBouton()
{
Text = "www.mesexemples.com";
Button bouton = new Button();
bouton.Parent = this;
bouton.Text = "Cliquez sur ce bouton";
bouton.Location = new Point(200, 100);
bouton.Size = new Size(90, 60);
// Attacher un événement à ce bouton
bouton.Click += new EventHandler(ButtonOnClick);
}
void ButtonOnClick(object obj, EventArgs ea)
{
Graphics g = CreateGraphics();
Point ptText = Point.Empty;
string str = "Vous avez cliqué sur le bouton";
// Dessiner un Text lorsque l'utilisateur clique sur le bouton
g.DrawString(str, Font, new SolidBrush(ForeColor), ptText);
g.Dispose();
}
}