System.Windows.Forms.PictureBox Class

Represents a Windows picture box control for displaying an image.

See Also: PictureBox Members

Syntax

[System.ComponentModel.DefaultBindingProperty("Image")]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Windows.Forms.Docking(System.Windows.Forms.DockingBehavior.Ask)]
[System.ComponentModel.Designer("System.Windows.Forms.Design.PictureBoxDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")]
[System.ComponentModel.DefaultProperty("Image")]
public class PictureBox : Control, System.ComponentModel.ISupportInitialize

Remarks

Typically the System.Windows.Forms.PictureBox is used to display graphics from a bitmap, metafile, icon, JPEG, GIF, or PNG file.

Set the PictureBox.Image property to the System.Drawing.Image you want to display, either at design time or at run time. You can alternatively specify the image by setting the PictureBox.ImageLocation property and load the image synchronously using the erload:System.Windows.Forms.PictureBox.Load method or asynchronously using the erload:System.Windows.Forms.PictureBox.LoadAsync method.

Note:

If you want to use the same image in multiple System.Windows.Forms.PictureBox controls, create a clone of the image for each System.Windows.Forms.PictureBox. Accessing the same image from multiple controls causes an exception to occur.

The PictureBox.SizeMode property, which is set to values in the System.Windows.Forms.PictureBoxSizeMode enumeration, controls the clipping and positioning of the image in the display area. You can change the size of the display area at run time with the Control.ClientSize property.

By default, the System.Windows.Forms.PictureBox control is displayed by without any borders. You can provide a standard or three-dimensional border using the PictureBox.BorderStyle property to distinguish the picture box from the rest of the form, even if it contains no image. The System.Windows.Forms.PictureBox is not a selectable control, which means that it cannot receive input focus.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0