获取或设置一个值,该值指示在多行文本框控件中按 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);
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. 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!"; }
[C++, JScript] 没有可用于 C++ 或 JScript 的示例。若要查看 Visual Basic 或 C# 示例,请单击页左上角的“语言筛选器”按钮
。| TextBoxBase 成员(Visual J# 语法) | C++ 托管扩展编程
发送有关此主题的意见 © 2001-2002 Microsoft Corporation。保留所有权利。
[Visual Basic]Public Property AcceptsReturn As Boolean
[C#]public bool AcceptsReturn {get; set;}
[C++]public: __property bool get_AcceptsReturn();public: __property void set_AcceptsReturn(bool);
[JScript]public function get AcceptsReturn() : Boolean;public function set AcceptsReturn(Boolean);
true;如果按 ENTER 键时激活窗体的默认按钮,则为 false。默认为 false。
false,则用户必须按 CTRL+ENTER 键才能在多行 TextBox 控件中创建一个新行。如果该窗体没有默认按钮,则按 ENTER 键时将总是会在控件中创建一行新文本,不管该属性的值是什么。
虽然可将 AcceptsReturn 设置成 false,但它始终与设置成 true 一样运行。如果希望使用 ENTER 键激活特殊的按钮,可从 TextBox 派生一个类,并在发生 KeyPress 事件时为 ENTER 键提供事件处理代码。
[Visual Basic, C#, JScript] 以下示例创建一个带垂直滚动条的多行 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 to be entered 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. textBox1.Multiline = true; // Add vertical scroll bars to the TextBox control. textBox1.ScrollBars = ScrollBars.Vertical; // Allow the RETURN key to be entered 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!"; }
[JScript] public function CreateMyMultilineTextBox() { // Create an instance of a TextBox control. 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 to be entered 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!"; }
[C++] 没有可用于 C++ 的示例。若要查看 Visual Basic、C# 或 JScript 示例,请单击页左上角的“语言筛选器”按钮
。| TextBox 成员(Visual J# 语法) | C++ 托管扩展编程
发送有关此主题的意见 © 2001-2002 Microsoft Corporation。保留所有权利。
指示多行文本框控件在必要时是否自动换行到下一行的开始。
[Visual Basic]Public Property WordWrap As Boolean
[C#]public bool WordWrap {get; set;}
[C++]public: __property bool get_WordWrap();public: __property void set_WordWrap(bool);
[JScript]public function get WordWrap() : Boolean;public function set WordWrap(Boolean);
true;如果当用户键入的内容超过了控件的右边缘时,文本框控件自动水平滚动,则为 false。默认为 true。
true,则不管 ScrollBars 属性的设置是什么,都不会显示水平滚动条。
HorizontalAlignment.Left。[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. 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!"; }
[C++, JScript] 没有可用于 C++ 或 JScript 的示例。若要查看 Visual Basic 或 C# 示例,请单击页左上角的“语言筛选器”按钮
。| TextBoxBase 成员(Visual J# 语法) | C++ 托管扩展编程
发送有关此主题的意见 © 2001-2002 Microsoft Corporation。保留所有权利。