This topic has not yet been rated - Rate this topic

ContentAlignment Enumeration

Specifies alignment of content on the drawing surface.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)
public enum ContentAlignment
Member name Description
TopLeft Content is vertically aligned at the top, and horizontally aligned on the left.
TopCenter Content is vertically aligned at the top, and horizontally aligned at the center.
TopRight Content is vertically aligned at the top, and horizontally aligned on the right.
MiddleLeft Content is vertically aligned in the middle, and horizontally aligned on the left.
MiddleCenter Content is vertically aligned in the middle, and horizontally aligned at the center.
MiddleRight Content is vertically aligned in the middle, and horizontally aligned on the right.
BottomLeft Content is vertically aligned at the bottom, and horizontally aligned on the left.
BottomCenter Content is vertically aligned at the bottom, and horizontally aligned at the center.
BottomRight Content is vertically aligned at the bottom, and horizontally aligned on the right.

The following code example demonstrates how to use the Point.Point and Size constructors and the System.Drawing.ContentAlignment enumeration. To run this example paste this code into a Windows Form that contains a label named Label1 and call the IntializeLabel1 method in the form's constructor.


private void InitializeLabel1()
{
    // Set a border.
    Label1.BorderStyle = BorderStyle.FixedSingle;

    // Set the size, constructing a size from two integers.
    Label1.Size = new Size(100, 50);

    // Set the location, constructing a point from a 32-bit integer
    // (using hexadecimal).
    Label1.Location = new Point(0x280028);

    // Set and align the text on the lower-right side of the label.
    Label1.TextAlign = ContentAlignment.BottomRight;
    Label1.Text = "Bottom Right Alignment";
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ