获取或设置一个值,该值指示在多行文本框控件中按 TAB 键时,是否在控件中键入一个 TAB 字符,而不是按选项卡的顺序将焦点移动到下一个控件。
[Visual Basic]
Public Property AcceptsTab As Boolean
[C#]
public bool AcceptsTab {get; set;}
[C++]
public: __property bool get_AcceptsTab();
public: __property void set_AcceptsTab(bool);
[JScript]
public function get AcceptsTab() : Boolean;
public function set AcceptsTab(Boolean);
属性值
如果用户可以使用 TAB 键在多行文本框控件中输入 TAB 字符,则为 true;如果按 TAB 键移动焦点,则为 false。默认为 false。
备注
如果将 AcceptsTab 属性设置为 true,则用户必须按 CTRL+TAB 键将焦点移动到 Tab 键顺序中的下一个控件。
示例
[Visual Basic, C#] 以下示例使用派生类 TextBox 来创建一个带垂直滚动条的多行 TextBox 控件。此示例还使用 AcceptsTab、AcceptsReturn 和 WordWrap 属性来使多行文本框控件可用于创建文本文档。
[Visual Basic]
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!"
End Sub
[C#]
public void CreateMyMultilineTextBox()
{
// Create an instance of a TextBox control.
TextBox textBox1 = new TextBox();
// Set the Multiline property to true.
textBox