Difference Between Label.Text And TextBox.Text (WinForms) In Treating Line Breaks
I had a small project recently that outputted the results of some calculations to the label on the form, I replaced the label with a textbox and noticed that instead of the line breaks I had in the label I got a bunch of non-printed characters. I had the following code that worked fine for the label:
[code:c#]
myLabel.Text += "\nNew Line";
[/code]
However as I said it didn’t work properly for the textbox, however this one did work:
[code:c#]
myTextBox.Text += "\r\nNew line";
[/code]
This is good and it also works with the Label control, however you can do it better by using Environment.NewLine which represents the new line string on the current system:
[code:c#]
myTextBox.Text += Environment.NewLine + "New line";
[/code]