Basically i display the some text in the MessageBox
with Ok
and Cancel
button in WindowPhone 7.1.
I need the requirement like the below.
Some text will be here....
Property:value...
Actually we can simply the text in the MessageBox, but how can i add the linebreak between the text in the MessageBox.. Is there any way to do this in Windows Phone?
您可以使用Environment.Newline进行换行
string msg = "Text here" + Environment.NewLine + "some other text";
MessageBox.Show("Line 1" + Environment.NewLine + "Line 2");
You can try
\\n or <br />
for line Breaks. I am not sure if this will work:
Example:
string msg = "Some text will be here\nProperty:value";
MessageBox.Show(msg);
MessageBox.Show("aa" + Environment.NewLine + Environment.NewLine + "bb");
This is a old post, but... If your text comes from resource file, none of the suggested solution works. In VS resource editor, you have to use Shift+Enter to enter new line. All others will just show as raw text like "\\n" or, "\\r\\n" or "<br />".
\\n
and Environment.NewLine
Option 1: \\n
I don't know if this work for sure on Windows phone but I think it would
\\n
- New line. Place as much as sentences as you want
MessageBox.Show("Some Text Here In The Line NO.1\nSome Text Here In Line NO.2");
Will show:
Some Text Here In The Line NO.1
Some Text Here In Line NO.2
OR
MessageBox.Show("Some Text Here In The Line NO.1 +"\n" + "Some Text Here In Line NO.2");
Will show the same as the first one:
Some Text Here In The Line NO.1
Some Text Here In Line NO.2
Option 2: Environment.NewLine
Environment.NewLine
- New line. Place as much as sentences as you want
MessageBox.Show("Some Text Here In The Line NO.1" + Environment.NewLine + "Some Text Here In Line NO.2");
Will show the same as the first one:
Some Text Here In The Line NO.1
Some Text Here In Line NO.2
From msdn.microsoft
The functionality provided by NewLine (Environment.NewLine) is often what is meant by the terms newline, line feed, line break, carriage return, CRLF, and end of the line.
I prefer \\n because is shorter and faster but whatever you like.
If you have a very very large message to display, use:
MessageBox.Show(String.Join(Environment.NewLine,
"Line 1",
"Line 2",
"Line 3"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.