C# – How to get single new line in a Rich Text Box to appear as single-spaced

crichtextboxwpf

I have a RichTextBox on a WPF window that I am using kind of like console output (output only). When I add a NewLine as in:

rtx_report.AppendText(lclFileInfo.pathOnly + System.Environment.NewLine);

it correctly adds just a single new line. (I know this from copying the text out of the box and pasting it somewhere else.) However, in the display it shows an additional whitespace row. So I started browsing the RichTextBox properties, but I am not sure which setting controls this.

It looks like it is just defaulting to double-spaced text, but I do not see anything that controls this. Can anyone explain how to get it to be single-spaced or otherwise not show that extra line?

TIA,

Paul

== Edit ==

P.S. More info as requested by HatSoft

The string content of lclFileInfo.pathOnly is
C:\Users\Paul\Documents\Roadway

However, the same problem happens on all of these lines of code:

rtx_report.AppendText("File Changed:" + System.Environment.NewLine);
rtx_report.AppendText(lclFileInfo.pathOnly + System.Environment.NewLine);
if (lclFileInfo.isDirectory == false)
        rtx_report.AppendText(lclFileInfo.fileNameOnly + System.Environment.NewLine);
rtx_report.AppendText("Changed On: " + lclFileInfo.currentTimestamp + System.Environment.NewLine);

Best Answer

Try this

rtx_report.AppendText(lclFileInfo.pathOnly + "\r");
Related Topic