How to get one new line in Rich Text Box to display as a one-time

I have a RichTextBox in a WPF window that I use as console output (output only). When I add NewLine, as in:

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

it correctly adds only one new line. (I know this by copying text from a box and pasting it somewhere else.) However, the display shows an extra line of spaces. So I started looking at the properties of RichTextBox, but I'm not sure which settings control this.

It seems like this is simply a failure to duplicate, but I don't see anything that controls this. Can someone explain how to make it be single line or not show this extra line otherwise?

TIA

Floor

== Edit ==

PS Further information on request HatSoft

String content lclFileInfo.pathOnly C: \ Users \ Paul \ Documents \ ROAD

However, the same problem occurs in all 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); 
+8
source share
2 answers

try it

 rtx_report.AppendText(lclFileInfo.pathOnly + "\r"); 
+13
source

In Xaml, set the property property of the RichTextBox paragraph property to zero. Setting it to 0 will not add extra line spacing.

 <RichTextBox AcceptsReturn="True"> <RichTextBox.Resources> <Style TargetType="{x:Type Paragraph}"> <Setter Property="Margin" Value="0" /> </Style> </RichTextBox.Resources> </RichTextBox> 
0
source

Source: https://habr.com/ru/post/919014/


All Articles