user1143606
user1143606

Reputation:

C# need to use enter key in multiline texbox to move down one line, not leave the texbox

In C# I have a multiline TextBox that users enter case notes into. However, when they enter the text box and hit the Enter key, it leaves the text box and jumps to the next field like the tab button. Is there any way to override this behavior and make the return key move down a line? I don't need to disable the return key behavior on the entire form, only in the one multiline text box.

Upvotes: 1

Views: 7687

Answers (2)

Steve
Steve

Reputation: 216273

You need to set the property

 textBox.AcceptsReturn = true;

Without this property you could use CTRL+ENTER to initiate a newline.
Sometimes this is useful if you need to have a default AcceptButton also set on the form.

See MSDN documentation

Upvotes: 12

SLaks
SLaks

Reputation: 887305

Set the AcceptsReturn property to true.

Upvotes: 1

Related Questions