This documentation is archived and is not being maintained.

Label.TextAlign Property

Gets or sets the alignment of text in the label.

[Visual Basic]
Public Overridable Property TextAlign As ContentAlignment
public virtual ContentAlignment TextAlign {get; set;}
public: __property virtual ContentAlignment get_TextAlign();
public: __property virtual void set_TextAlign(ContentAlignment);
public function get TextAlign() : ContentAlignment;
public function set TextAlign(ContentAlignment);

Property Value

One of the ContentAlignment values. The default is TopLeft.


Exception Type Condition
InvalidEnumArgumentException The value assigned is not one of the ContentAlignment values.


You can use this property to align the text within a label to match the layout of controls on your form. For example, if your controls are located to the right edge of the labels, you can set the TextAlign property to one of the right-aligned horizontal alignments (TopRight, MiddleRight, BottomRight) and the text will be aligned with the right edge of the labels to align with your controls.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

Label Class | Label Members | System.Windows.Forms Namespace | ContentAlignment