PictureBox::SizeMode Property

 

Indicates how the image is displayed.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public:
property PictureBoxSizeMode SizeMode {
	PictureBoxSizeMode get();
	void set(PictureBoxSizeMode value);
}

Property Value

Type: System.Windows.Forms::PictureBoxSizeMode

One of the PictureBoxSizeMode values. The default is Normal.

Exception Condition
InvalidEnumArgumentException

The value assigned is not one of the PictureBoxSizeMode values.

Valid values for this property are taken from the PictureBoxSizeMode enumeration.

By default, in Normal mode, the Image is positioned in the upper-left corner of the PictureBox, and any part of the image that is too big for the PictureBox is clipped. Using the StretchImage value causes the image to stretch or shrink to fit the PictureBox. Using the Zoom value causes the image to be stretched or shrunk to fit the PictureBox; however, the aspect ratio in the original is maintained.

Using the AutoSize value causes the control to resize to always fit the image. Using the CenterImage value causes the image to be centered in the client area.

The following code example demonstrates the use of the SizeMode property. To run this example, paste the following code into a Windows Form and call the InitializePictureBoxAndButton method from the form's constructor or Load-event handling method.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: