NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

TextBox.AcceptsReturn

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);

Property Value

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.

Remarks

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.

Example [Visual Basic]

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

See Also

TextBox Class | TextBox Members | System.WinForms Namespace