Assembly : System.Windows.Forms (dans system.windows.forms.dll)
Syntaxe<ComVisibleAttribute(True)> _ <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ Public Class PictureBox Inherits Control Implements ISupportInitialize
Dim instance As PictureBox
[ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] public class PictureBox : Control, ISupportInitialize
[ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] public ref class PictureBox : public Control, ISupportInitialize
/** @attribute ComVisibleAttribute(true) */ /** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ public class PictureBox extends Control implements ISupportInitialize
ComVisibleAttribute(true) ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) public class PictureBox extends Control implements ISupportInitialize
NotesEn général, PictureBox est utilisé pour afficher des graphismes issus de fichiers bitmap, icône, JPEG, GIF, PNG ou de métafichiers.
Affectez à la propriété Image l'objet Image à afficher au moment du design ou de l'exécution. Vous pouvez spécifier l'image en définissant la propriété ImageLocation et la charger de façon synchrone à l'aide de la méthode Load ou de façon asynchrone à l'aide de la méthode LoadAsync. La propriété SizeMode à laquelle sont affectées des valeurs dans l'énumération PictureBoxSizeMode contrôle le découpage et le positionnement de l'image dans la zone d'affichage. Vous pouvez modifier la taille de la zone d'affichage au moment de l'exécution à l'aide de la propriété ClientSize.
Par défaut, le contrôle PictureBox est affiché sans bordure. La propriété BorderStyle vous permet de lui affecter une bordure standard ou 3D qui permettra de distinguer la zone d'image du reste du formulaire même si elle ne contient pas d'image. PictureBox n'est pas un contrôle sélectionnable, ce qui signifie qu'il ne peut pas recevoir de focus d'entrée.
ExempleL'exemple de code suivant montre comment définir une image et redimensionner la zone d'affichage de la zone d'image. Cet exemple part du principe qu'un ShowMyImage est appelé à partir d'un formulaire existant et que l'espace de noms System.Drawing a été ajouté au code source de votre formulaire.
Private MyImage As Bitmap Public Sub ShowMyImage(fileToDisplay As String, xSize As Integer, _ ySize As Integer) ' Sets up an image object to be displayed. If (MyImage IsNot Nothing) Then MyImage.Dispose() End If ' Stretches the image to fit the pictureBox. pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage MyImage = New Bitmap(fileToDisplay) pictureBox1.ClientSize = New Size(xSize, ySize) pictureBox1.Image = CType(MyImage, Image) End Sub
private Bitmap MyImage ; public void ShowMyImage(String fileToDisplay, int xSize, int ySize) { // Sets up an image object to be displayed. if (MyImage != null) { MyImage.Dispose(); } // Stretches the image to fit the pictureBox. pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage ; MyImage = new Bitmap(fileToDisplay); pictureBox1.ClientSize = new Size(xSize, ySize); pictureBox1.Image = (Image) MyImage ; }
Bitmap^ MyImage; public: void ShowMyImage( String^ fileToDisplay, int xSize, int ySize ) { // Sets up an image object to be displayed. if ( MyImage != nullptr ) { delete MyImage; } // Stretches the image to fit the pictureBox. pictureBox1->SizeMode = PictureBoxSizeMode::StretchImage; MyImage = gcnew Bitmap( fileToDisplay ); pictureBox1->ClientSize = System::Drawing::Size( xSize, ySize ); pictureBox1->Image = dynamic_cast<Image^>(MyImage); }
private Bitmap myImage; public void ShowMyImage(String fileToDisplay, int xSize, int ySize) { // Sets up an image object to be displayed. if (myImage != null) { myImage.Dispose(); } // Stretches the image to fit the pictureBox. pictureBox1.set_SizeMode(PictureBoxSizeMode.StretchImage); myImage = new Bitmap(fileToDisplay); pictureBox1.set_ClientSize(new Size(xSize, ySize)); pictureBox1.set_Image(myImage); } //ShowMyImage
Hiérarchie d'héritageSystem.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.PictureBox
Sécurité des threads
Plates-formesWindows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile pour Pocket PC, Windows Mobile pour Smartphone, Windows Server 2003, Windows XP Édition Media Center, Windows XP Professionnel Édition x64, Windows XP SP2, Windows XP Starter Edition
Le .NET Framework ne prend pas en charge toutes les versions de chaque plate-forme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise.
Informations de version
Outils (masquer)
S'enregistrer
Liste des Membres
Qui est en ligne?
FAQ