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.

例外狀況

指派給這個屬性的值不是型別 HorizontalAlignmentThe 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.

適用於

另請參閱