
{filelink=14622}
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace MaPictureBox
{
public class ExemplePictureBox : System.Windows.Forms.Form
{
PictureBox zoneImage1;
Button boutonAfficher;
PictureBox zoneImage2;
PictureBox zoneImage3;
PictureBox zoneImage4;
private System.ComponentModel.Container components = null;
public ExemplePictureBox()
{
InitializeComponent();
this.Text = "Dimensionner les images";
this.boutonAfficher.Text = "Afficher les images";
ToolTip infoBulle = new ToolTip();
//Ajouter une InfoBulle à notre bouton
infoBulle.SetToolTip(boutonAfficher, "Les images s'affiche en plusieurs dimensions");
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.zoneImage1 = new System.Windows.Forms.PictureBox();
this.boutonAfficher = new System.Windows.Forms.Button();
this.zoneImage2 = new System.Windows.Forms.PictureBox();
this.zoneImage3 = new System.Windows.Forms.PictureBox();
this.zoneImage4 = new System.Windows.Forms.PictureBox();
this.SuspendLayout();
//
// zoneImage1
//
this.zoneImage1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.zoneImage1.Location = new System.Drawing.Point(8, 8);
this.zoneImage1.Name = "zoneImage1";
this.zoneImage1.Size = new System.Drawing.Size(100, 70);
this.zoneImage1.TabIndex = 0;
this.zoneImage1.TabStop = false;
//
// boutonAfficher
//
this.boutonAfficher.Location = new System.Drawing.Point(232, 24);
this.boutonAfficher.Name = "boutonAfficher";
this.boutonAfficher.Size = new System.Drawing.Size(120, 23);
this.boutonAfficher.TabIndex = 1;
this.boutonAfficher.Text = "boutonAfficher";
this.boutonAfficher.Click += new System.EventHandler(this.boutonAfficher_Click);
//
// zoneImage2
//
this.zoneImage2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.zoneImage2.Location = new System.Drawing.Point(120, 8);
this.zoneImage2.Name = "zoneImage2";
this.zoneImage2.Size = new System.Drawing.Size(100, 70);
this.zoneImage2.TabIndex = 0;
this.zoneImage2.TabStop = false;
//
// zoneImage3
//
this.zoneImage3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.zoneImage3.Location = new System.Drawing.Point(8, 88);
this.zoneImage3.Name = "zoneImage3";
this.zoneImage3.Size = new System.Drawing.Size(100, 70);
this.zoneImage3.TabIndex = 0;
this.zoneImage3.TabStop = false;
//
// zoneImage4
//
this.zoneImage4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.zoneImage4.Location = new System.Drawing.Point(120, 88);
this.zoneImage4.Name = "zoneImage4";
this.zoneImage4.Size = new System.Drawing.Size(100, 70);
this.zoneImage4.TabIndex = 0;
this.zoneImage4.TabStop = false;
//
// ExemplePictureBox
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(376, 254);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.boutonAfficher,
this.zoneImage2,
this.zoneImage3,
this.zoneImage4,
this.zoneImage1});
this.Name = "ExemplePictureBox";
this.Text = "ExemplePictureBox";
this.ResumeLayout(false);
}
[STAThread]
static void Main()
{
Application.Run(new ExemplePictureBox());
}
private void boutonAfficher_Click(object sender, System.EventArgs e)
{
SetPictureBoxSizeMode();
}
private void SetPictureBoxSizeMode()
{
String urlImage = @"C:Documents and SettingsAdministrateurMes documentshalf.png";
// Afficher l'image dans nos composants PictureBox en plusieurs dimension
zoneImage1.SizeMode = PictureBoxSizeMode.CenterImage;
zoneImage1.Image = Image.FromFile(urlImage);
zoneImage2.SizeMode = PictureBoxSizeMode.Normal;
zoneImage2.Image = Image.FromFile(urlImage);
zoneImage3.SizeMode = PictureBoxSizeMode.StretchImage;
zoneImage3.Image = Image.FromFile(urlImage);
zoneImage4.SizeMode = PictureBoxSizeMode.AutoSize;
zoneImage4.Image = Image.FromFile(urlImage);
}
}
}