Label.TextAlign Property
Gets or sets the alignment of text in the label.
[Visual Basic] Public Overridable Property TextAlign As ContentAlignment [C#] public virtual ContentAlignment TextAlign {get; set;} [C++] public: __property virtual ContentAlignment get_TextAlign(); public: __property virtual void set_TextAlign(ContentAlignment); [JScript] public function get TextAlign() : ContentAlignment; public function set TextAlign(ContentAlignment);
Property Value
One of the ContentAlignment values. The default is TopLeft.
Exceptions
| Exception Type | Condition |
|---|---|
| InvalidEnumArgumentException | The value assigned is not one of the ContentAlignment values. |
Remarks
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.
Requirements
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