MaskedTextBox.TextAlign Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets how text is aligned in a masked text box control.

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

public HorizontalAlignment TextAlign { get; set; }
/** @property */
public HorizontalAlignment get_TextAlign ()

/** @property */
public void set_TextAlign (HorizontalAlignment value)

public function get TextAlign () : HorizontalAlignment

public function set TextAlign (value : HorizontalAlignment)

Property Value

One of the HorizontalAlignment enumeration values that specifies how text is aligned relative to the control. The default is Left.

Exception typeCondition


The value assigned to this property is not of type HorizontalAlignment.

You can use the TextAlign property to align the displayed text within a MaskedTextBox to match the layout of visual elements on your form. For example, if your controls are all located on the right side of the form, you can set the TextAlign property to Right, and the text will be aligned with the right side of the control instead of the default left alignment.

Windows 98, Windows 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions