In a TextBox, with the MultiLine property true, the character \ n does not change the line

0

In a TextBox the character \n does not change the text line, eg:

textBox1.Multiline = true;
textBox1.Text = "IMPRIMEEMCIMA\nIMPRIMEEMBAIXO";

However, the \t character works. I also noticed that on a label the same text prints the line change but does not print the tab, \ t. In a MessageBox and Console application everything works fine.

    
asked by anonymous 28.06.2017 / 13:00

2 answers

5

Use Environment.NewLine , which returns a string specific to the platform in question:

  • "\ r \ n" (\ u000D \ u000A) for Windows
  • "\ n" (\ u000A) for Unix

Example:

textBox1.Text = "IMPRIMEEMCIMA" + Environment.NewLine + "IMPRIMEEMBAIXO";
    
28.06.2017 / 13:16
1

To break the line in the TextBox you should do \r\n

    
28.06.2017 / 13:36