In a Textbox, with the property Multiline true, character n does not change line

Asked

Viewed 591 times

0

In a Textbox the character \n does not change line text, example:

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

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

  • I think you have to do \r\n

  • Works, thank you!

  • All right, I’ll answer then

2 answers

5

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

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

Example:

textBox1.Text = "IMPRIMEEMCIMA" + Environment.NewLine + "IMPRIMEEMBAIXO";
  • It worked, thank you!

1

To break the line in the Textbox you must do \r\n

Browser other questions tagged

You are not signed in. Login or sign up in order to post.