共用方式為


ToolStripTextBox.TextBoxTextAlign 屬性

定義

取得或設定在 TextBox 控制項中文字的對齊方式。

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

屬性值

其中一個 HorizontalAlignment 列舉值,指出在控制項中文字的對齊方式。 預設為 Left

範例

下列程式碼範例示範設定各種 ToolStripTextBox 通用屬性設定的語法,包括 TextBoxTextAlign 屬性 。

// This code example demonstrates the syntax for setting
// various ToolStripTextBox properties.
// 
toolStripTextBox1.AcceptsReturn = true;
toolStripTextBox1.AcceptsTab = true;
toolStripTextBox1.AutoCompleteCustomSource.AddRange(new string[] {
"This is line one.",
"Second line.",
"Another line."});
toolStripTextBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
toolStripTextBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
toolStripTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
toolStripTextBox1.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
toolStripTextBox1.HideSelection = false;
toolStripTextBox1.MaxLength = 32000;
toolStripTextBox1.Name = "toolStripTextBox1";
toolStripTextBox1.ShortcutsEnabled = false;
toolStripTextBox1.Size = new System.Drawing.Size(100, 25);
toolStripTextBox1.Text = "STRING1\r\nSTRING2\r\nSTRING3\r\nSTRING4";
toolStripTextBox1.TextBoxTextAlign = System.Windows.Forms.HorizontalAlignment.Center;
' This code example demonstrates the syntax for setting
' various ToolStripTextBox properties.
' 
toolStripTextBox1.AcceptsReturn = True
toolStripTextBox1.AcceptsTab = True
toolStripTextBox1.AutoCompleteCustomSource.AddRange(New String() {"This is line one.", "Second line.", "Another line."})
toolStripTextBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend
toolStripTextBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource
toolStripTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
toolStripTextBox1.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
toolStripTextBox1.HideSelection = False
toolStripTextBox1.MaxLength = 32000
toolStripTextBox1.Name = "toolStripTextBox1"
toolStripTextBox1.ShortcutsEnabled = False
toolStripTextBox1.Size = New System.Drawing.Size(100, 25)
toolStripTextBox1.Text = "STRING1" + ControlChars.Cr + ControlChars.Lf + "STRING2" + ControlChars.Cr + ControlChars.Lf + "STRING3" + ControlChars.Cr + ControlChars.Lf + "STRING4"
toolStripTextBox1.TextBoxTextAlign = System.Windows.Forms.HorizontalAlignment.Center

備註

您可以使用這個屬性來對齊 內的 TextBox 文字,以符合表單上的文字配置。 例如,如果您的控制項全都位於表單的右側,您可以將 屬性設定 TextBoxTextAlignRight ,而且文字會對齊控制項的右側,而不是預設的左對齊方式。

適用於