Label.ImageAlign Property


Gets or sets the alignment of an image that is displayed in the control.

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

member ImageAlign : ContentAlignment with get, set

Property Value

Type: System.Drawing.ContentAlignment

One of the ContentAlignment values. The default is ContentAlignment.MiddleCenter.

Exception Condition

The value assigned is not one of the ContentAlignment values.

This property enables you to align an image within the boundaries of the Label control to ensure that the image is properly displayed. You can add an image to a Label using the Image property or the ImageList and ImageIndex properties. Images displayed in the control cannot be stretched or shrunk to fill the control if the control is larger or smaller than the image.

The following code example demonstrates how to create a Label control that has a three-dimensional border and an image displayed using the ImageList and ImageIndex properties. The control also has a caption with a mnemonic character specified. The example code uses the PreferredHeight and PreferredWidth properties to properly size the Label control on the form on which it is displayed. This example requires that an ImageList has been created and named imageList1 and that it has loaded two images. The example also requires that the code is within a form that has the System.Drawing namespace added to its code.

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

.NET Framework
Available since 1.1
Return to top