Exemple d’utilisation de la classe ‘Bitmap’: Ajouter une icône à un bouton

Author:

Exemple,d'utilisation,de,la,classe,'Bitmap':,Ajouter,une,icône,à,un,bouton
{filelink=14643}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

public class ImageBouton : Form
{
    private System.Windows.Forms.Button btn;

 [STAThread]
  static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new ImageBouton());
  }

  public ImageBouton() {
        InitializeComponent();
  }

    private void InitializeComponent()
    {
        Text = "Exemple d'un bouton avec image";
        this.btn = new System.Windows.Forms.Button();
        this.SuspendLayout();

        this.btn.Image = new Bitmap(@"C:Documents and SettingsAdministrateurMes documentsIconssaveas_edit.gif");
        this.btn.ImageAlign = System.Drawing.ContentAlignment.TopRight;
        this.btn.Location = new System.Drawing.Point(12, 99);
        this.btn.Name = "btn";
        this.btn.TabIndex = 1;
        this.btn.Text = "Bouton1";
        this.btn.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
        this.btn.UseVisualStyleBackColor = true;

        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(299, 271);

        this.Controls.Add(this.btn);
        this.Font = new System.Drawing.Font("Tahoma", 12.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        this.Name = "imageBouton";
        this.ResumeLayout(false);

    }

}

Leave a Reply

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