Text in the message box should be the next next lines

妖精的绣舞 提交于 2019-11-28 09:46:14

You can use Environment.Newline for line breaks

string msg = "Text here" + Environment.NewLine + "some other text";
MessageBox.Show("Line 1" + Environment.NewLine + "Line 2");
SHAKIR SHABBIR

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");

There are 2 options \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.

newman

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 />".

If you have a very very large message to display, use:

MessageBox.Show(String.Join(Environment.NewLine,
                            "Line 1",
                            "Line 2",
                            "Line 3"));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!