easy one // textBox.text and return/new line character....

  • Thread starter Thread starter genc ymeri
  • Start date Start date
G

genc ymeri

Hi ,
I have this simple code :

string hopeTextShowsInTwoLines = "lineOne \n line two";
textBox1.Text = hopeTextShowsInTwoLines;

but text shows in one line. What should I do for thenew lines "\n"
characters to send the rest of the text in the new line of the textBox ?

THank You
 
Hi genc ymeri,

First, you should use \r\n and not just \n, as you aren't always
guaranteed that just \n will work.

In your case you need to set the TextBox's MultiLine property to true.
 
Morten Wennevik said:
First, you should use \r\n and not just \n

"\r\n" can be used if you only intend your application to run under
Windows.

If you're concerned about portability, use Environment.NewLine.

P.
 
thnx :)

Paul E Collins said:
"\r\n" can be used if you only intend your application to run under
Windows.

If you're concerned about portability, use Environment.NewLine.

P.
 
Paul E Collins said:
"\r\n" can be used if you only intend your application to run under
Windows.

If you're concerned about portability, use Environment.NewLine.

I don't know about that - Environment.NewLine is to do with the new
line for the platform in general. There's no guarantee it'll be what
the *text box* uses for a new line. For instance, running with Mono
under Linux, I'd expect Environment.NewLine to be '\n' but if they're
trying to get Windows Forms compatibility with .NET, TextBox may well
still require '\r\n'.
 
Back
Top