I think you want to add a feature to the TextBox control to move to the next line when the user presses enter key, right?
The default behaviour of the TextBox is to deny the user to go to the next line by pressing Enter key. That is when the user presses the enter key, even if the TextBox is multiline (enough height for multiple lines) the new line request would be denied. You can overcome this behaviour by adding an attribute or a C# property to the object.
AcceptsReturn
attribute of the object determines whether the TextBox would accept the user's request to move to the next line, or not. It depends on the value. If you set it to
true
the TextBox would allow the user now to move to the next line. You don't need to handle the event, TextBox would handle it for you.
Hopefully you'll be using WPF, you can do that in the Markup like
<textbox name="myTextBox" acceptsreturn="True" />
The above line includes and attribute,
AcceptsReturn
which enables or disables the textbox to allow the user to move to the next line using the enter key.
A C# solution to this would be like the following code,
myTextBox.AcceptsReturn = true;
.. this will now allow the user to go to the next line once he presses enter key. The data will be saved in the TextBox and you can get that data using
myTextBox.Text
property. It will be multiline (if user has added multiline data).
For more on this:
http://msdn.microsoft.com/en-us/library/system.windows.controls.textbox.acceptsreturn(v=VS.95).ASPX[
^]