Reputation: 867
Any way to convert a RichTextBox content and convert it to a single line in a String variable?
I have this:
string line = Document.Text; //Convierte el contenido en una sola línea.
string singleLine=line.Replace("\r\n", " ");
When show that in a MessageBox, it still appears in multiple lines.
Thanks in advance!
Upvotes: 1
Views: 707
Reputation: 216351
The MessageBox has a finite length of space to show its message.
When there is no more space it continues to print your text on a newline but it doesn't modify anything in your message.
To check if your code has effectively removed the newlines try to print in the output window with
Console.WriteLine(singleline);
Also, I prefer to use Environment.NewLine instead of the escape codes specific to the current operating system
string singleLine=line.Replace(Environment.NewLine, " ");
Upvotes: 2