TextBoxBase.AcceptsTab TextBoxBase.AcceptsTab TextBoxBase.AcceptsTab TextBoxBase.AcceptsTab Property

定义

获取或设置一个值,该值指示在多行文本框控件中按 Tab 键时,是否在控件中键入一个 Tab 字符,而不是按选项卡的顺序将焦点移动到下一个控件。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

属性值

如果用户可以使用 Tab 键在多行文本框控件中输入 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

注解

属性还必须为以在控件中获取制表符。 true MultilineThe Multiline property must also be true to get a TAB character in the control.

如果属性设置为true,则用户必须按 CTRL + tab 将焦点按 tab 键顺序移到下一个控件。 AcceptsTabIf 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.

适用于

另请参阅