Gets or sets a value indicating whether pressing ENTER in a multiline TextBox control creates a new line of text in the control or activates the default button for the form.
[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 if the ENTER key creates a new line of text in the control; false if the ENTER key activates the default button for the form. The default is true.
If the value of this property is false, the user must press CTRL+ENTER to create a new line in a multiline TextBox control. If there is no default button for the form, then the ENTER key will always create a new line of text in the control, no matter what the value of this property.
The following example creates a multiline TextBox control with vertical scroll bars. This example uses the AcceptsTab, AcceptsReturn, and WordWrap properties to make the multiline text box control useful for creating text documents.
[Visual Basic]
Public Sub CreateMultilineTextBox() ' Create an instance of an TextBox control Dim TextBox1 as TextBox Set 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!" End Sub