Reputation: 125
I have something like this:
and i would like to have something like this:
Upvotes: 0
Views: 187
Reputation: 189
MessageBox.Show("It's Felix Birthday\nIt's DesBirthday\nIt's Fffffffs Birthday!");
Just put "\n" where you want to new line
Upvotes: 0
Reputation: 55
By using TextWrapping, you will be able to use multiline textbox.
TextWrapping="Wrap" MaxLines="2" Width="150"
Upvotes: -1
Reputation: 173
You should use Environment.NewLine
as suggested by Jonesopolis.
See the documentation here, the caracters for the new line depend on the system you are targeting. Let the .NET framework know what a new line is.
You can use it like that
string str = String.Format("this text{0}is on three{0}lines", Environment.NewLine);
Or, if you're using the last version of C# (can be less readable if you have a lot of new lines) :
string newLine = Environment.NewLine;
string str = $"this text is{newLine}on three{newLine}lines";
Upvotes: 3
Reputation: 12683
As stated before\r\n
is a good use to insert new lines. Alternatively (and my personal choice) is to use Environment.NewLine
which effectively does the same thing. However this is based on the Enviroment
and therefore should be cross environment compatible (all-be-it no other WPF environment exists).
Something like
string message = string.Format("It's Felix Birthday{0}It's DesBirthday{0}It's Fffffffs Birthday!", Environment.NewLine);
Really this will just produce the same result as entering in the \r\n
but also makes it a bit more readable.
Upvotes: 0
Reputation: 14995
Insert "\r\n" where ever you want to add line
"It's Felix Birthday\r\nIt's DesBirthday\r\nIt's Fffffffs Birthday!"
Upvotes: 3