Hi Morten,
I do have a multi line textbox,
if I do [ENTER] + additional text
the additional text is lost, i.e., not written.
I did already try
if(e.KeyChar == (char)13)
{
textBox1.Text += "\r\n";
}
That doesn't do the trick either.
I am working with an inherited form, maybe that
is a cause?
Paddy
"Morten Wennevik" <Mo************@hotmail.com> wrote in message
news:opr9sd3jnaklbvpo@morten_x.edunord...
Hi Paddy,
If you write in a single line textbox, hitting [ENTER] will not add a
carriage return. However, if you also write in a multiline textbox then any
[ENTER] you do will be saved with the rest of the text.
If you use a single line textbox, you can add your own \r\n whenever you
hit [ENTER] using the KeyPress event
private void textBox1_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e) {
if(e.KeyChar == (char)13) // 13 is the code for the carriage return
{
textBox1.Text += "\r\n"; // add cr and lf to the string
textBox1.SelectionStart = textBox1.TextLength; // move the cursor to the
end }
}
--
Happy coding!
Morten Wennevik [C# MVP]