MaskedTextBox.TextAlign 属性

定义

获取或设置掩码文本框控件中文本的对齐方式。Gets or sets how text is aligned in a masked text box control.

public:
 property System::Windows::Forms::HorizontalAlignment TextAlign { System::Windows::Forms::HorizontalAlignment get(); void set(System::Windows::Forms::HorizontalAlignment value); };
public System.Windows.Forms.HorizontalAlignment TextAlign { get; set; }
member this.TextAlign : System.Windows.Forms.HorizontalAlignment with get, set
Public Property TextAlign As HorizontalAlignment

属性值

HorizontalAlignment

HorizontalAlignment 枚举值之一,指定文本相对于控件的对齐方式。One of the HorizontalAlignment enumeration values that specifies how text is aligned relative to the control. 默认为 LeftThe default is Left.

例外

赋给该属性的值不是 HorizontalAlignment 类型。The value assigned to this property is not of type HorizontalAlignment.

注解

您可以使用 TextAlign 属性来对齐中显示的文本 MaskedTextBox ,以使其与窗体上的可视元素的布局相匹配。You can use the TextAlign property to align the displayed text within a MaskedTextBox to match the layout of visual elements on your form. 例如,如果控件都位于窗体的右侧,则可以将 TextAlign 属性设置为 Right ,并且文本将与控件的右侧对齐,而不是与默认的左对齐方式对齐。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.

适用于

另请参阅