To make a textbox display multi-line text, you must set its multiline attribute to true. However, if you want to set the text attribute of textbox to multi-line text, A line break consists of two characters: "\ r \ n ".
Textbox1.text = "first \ nsecond \ nthird"; Do not wrap the line when running.
In fact, it is mainly because textbox runs on Windows. The line feed that Windows can display must consist of two characters: "\ r \ n ".
If "\ n" is not displayed as a line break in Windows, it is different from other operating systems such as Linux/Unix. Therefore, you can replace "\ n" with "\ r \ n.
In fact, the problem is still not well solved, because "\ r \ n" can meet the requirements of windows, but what if it is another platform?
To ensure that the line feed effect can be properly displayed on various platforms, use system. environment. newline.
It can ensure that correct line breaks can be returned on different platforms. \ r \ n in windows and \ n in Linux. Therefore, the above Code should be written:
Atextbox. Text = "first line" + system. environment. newline + "second line" + system. environment. newline + "third line ";
C # use the text attribute of textbox to add the character "\ r \ n" to the line feed"