Création d’un application graphique simple: bouton, label, champs de text et boîte de dialogue

Author:

Création,d'un,application,graphique,simple:,bouton,,label,,champs,de,text,et,boîte,de,dialogue
{filelink=14640}

using System;
using System.Windows.Forms;

class MainForm : Form
{
    private Label label1;
    private TextBox champsText;
    private Button bouton;

    [STAThread]
     public static void Main()
     {
        Application.EnableVisualStyles();
        Application.Run(new MainForm());
     }
    public MainForm()
    {
         this.label1 = new Label();
         this.champsText = new TextBox();
         this.bouton = new Button();
         this.SuspendLayout();

         this.label1.Location = new System.Drawing.Point(16, 36);
         this.label1.Name = "label1";
         this.label1.Size = new System.Drawing.Size(128, 16);
         this.label1.TabIndex = 0;
         this.label1.Text = "tapez un texte ici:"; 

         this.champsText.Location = new System.Drawing.Point(152, 32);
         this.champsText.Name = "champsText";
         this.champsText.TabIndex = 1;
         this.champsText.Text = "";

         this.bouton.Location = new System.Drawing.Point(109, 80);
         this.bouton.Name = "bouton";
         this.bouton.TabIndex = 2;
         this.bouton.Text = "Afficher mon Texte";
         this.bouton.Size = new System.Drawing.Size(90, 60);
         this.bouton.Click += new System.EventHandler(this.bouton_Click);

         this.ClientSize = new System.Drawing.Size(292, 126);
         this.Controls.Add(this.bouton);
         this.Controls.Add(this.champsText);
         this.Controls.Add(this.label1);
         this.Name = "form1";
         this.Text = "Création d'une Form Simple";

         this.ResumeLayout(false);
     }
     private void bouton_Click(object sender, System.EventArgs e)
     {
        System.Console.WriteLine("Vous avez tapé: " + champsText.Text);
        MessageBox.Show("Votre text:, " + champsText.Text, "Exemple Boîte de dialogue");
     }

}

Leave a Reply

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