Export (0) Print
Expand All
0 out of 2 rated this helpful - 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
public enum ContentAlignment
public enum ContentAlignment
 Member nameDescription
BottomCenterContent is vertically aligned at the bottom, and horizontally aligned at the center. 
BottomLeftContent is vertically aligned at the bottom, and horizontally aligned on the left. 
BottomRightContent is vertically aligned at the bottom, and horizontally aligned on the right. 
MiddleCenterContent is vertically aligned in the middle, and horizontally aligned at the center. 
MiddleLeftContent is vertically aligned in the middle, and horizontally aligned on the left. 
MiddleRightContent is vertically aligned in the middle, and horizontally aligned on the right. 
Supported by the .NET Compact FrameworkTopCenterContent is vertically aligned at the top, and horizontally aligned at the center. 
Supported by the .NET Compact FrameworkTopLeftContent is vertically aligned at the top, and horizontally aligned on the left. 
Supported by the .NET Compact FrameworkTopRightContent is vertically aligned at the top, and horizontally aligned on the right. 

The following code example demonstrates how to use the System.Drawing.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";
}

private void Initializelabel1()
{
    // Set a border.
    label1.set_BorderStyle(BorderStyle.FixedSingle);

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

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

    // Set and align the text on the lower-right side of the label.
    label1.set_TextAlign(ContentAlignment.BottomRight);
    label1.set_Text("Bottom Right Alignment");
} //Initializelabel1

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.