TextBoxBase.AcceptsTab 屬性

定義

取得或設定值,指出在多行文字方塊控制項中按 TAB 鍵時,在控制項中輸入的是 TAB 字元,而不是將焦點 (Focus) 移至定位順序的下一個控制項。Gets or sets a value indicating whether pressing the TAB key in a multiline text box control types a TAB character in the control instead of moving the focus to the next control in the tab order.

public:
 property bool AcceptsTab { bool get(); void set(bool value); };
public bool AcceptsTab { get; set; }
member this.AcceptsTab : bool with get, set
Public Property AcceptsTab As Boolean

屬性值

Boolean

如果使用者可以用 TAB 鍵在多行文字方塊中輸入定位點,則為 true,如果按 TAB 鍵會移動焦點,則為 falsetrue if users can enter tabs in a multiline text box using the TAB key; false if pressing the TAB key moves the focus. 預設為 falseThe default is false.

範例

下列程式碼範例會使用 TextBox 衍生類別,以建立 TextBox 具有垂直捲動條的多行控制項。The following code example uses TextBox, a derived class, to create a multiline TextBox control with vertical scroll bars. 這個範例也會使用 AcceptsTabAcceptsReturnWordWrap 屬性,讓多行文字方塊控制項適合用來建立文字檔。This example also uses the AcceptsTab, AcceptsReturn, and WordWrap properties to make the multiline text box control useful for creating text documents.

public:
   void CreateMyMultilineTextBox()
   {
      // Create an instance of a TextBox control.
      TextBox^ textBox1 = gcnew TextBox;
      
      // Set the Multiline property to true.
      textBox1->Multiline = true;
      // Add vertical scroll bars to the TextBox control.
      textBox1->ScrollBars = ScrollBars::Vertical;
      // Allow the RETURN key in the TextBox control.
      textBox1->AcceptsReturn = true;
      // Allow the TAB key to be entered in the TextBox control.
      textBox1->AcceptsTab = true;
      // Set WordWrap to true to allow text to wrap to the next line.
      textBox1->WordWrap = true;
      // Set the default text of the control.
      textBox1->Text = "Welcome!" + Environment::NewLine + "Second Line";
   }
public void CreateMyMultilineTextBox()
 {
    // Create an instance of a TextBox control.
    TextBox textBox1 = new TextBox();
    
    // Set the Multiline property to true.
    textBox1.Multiline = true;
    // Add vertical scroll bars to the TextBox control.
    textBox1.ScrollBars = ScrollBars.Vertical;
    // Allow the RETURN key in the TextBox control.
    textBox1.AcceptsReturn = true;
    // Allow the TAB key to be entered in the TextBox control.
    textBox1.AcceptsTab = true;
    // Set WordWrap to true to allow text to wrap to the next line.
    textBox1.WordWrap = true;
    // Set the default text of the control.
    textBox1.Text = "Welcome!" + Environment.NewLine + "Second Line";
 }
Public Sub CreateMyMultilineTextBox()
    ' Create an instance of a TextBox control.
    Dim textBox1 As New TextBox()
    
    ' Set the Multiline property to true.
    textBox1.Multiline = True
    ' Add vertical scroll bars to the TextBox control.
    textBox1.ScrollBars = ScrollBars.Vertical
    ' Allow the RETURN key in the TextBox control.
    textBox1.AcceptsReturn = True
    ' Allow the TAB key to be entered in the TextBox control.
    textBox1.AcceptsTab = True
    ' Set WordWrap to true to allow text to wrap to the next line.
    textBox1.WordWrap = True
    ' Set the default text of the control.
    textBox1.Text = "Welcome!" & Environment.NewLine & "Second Line"
End Sub

備註

Multiline屬性也必須是 true ,才能取得控制項中的定位字元。The Multiline property must also be true to get a TAB character in the control.

如果 AcceptsTab 屬性設定為 true ,則使用者必須按 CTRL + tab 鍵,將焦點移至定位順序中的下一個控制項。If the AcceptsTab property is set to true, the user must press CTRL+TAB to move the focus to the next control in the tab order.

適用於

另請參閱