我在WPF窗口上有一个RichTextBox,我正在使用类似于控制台输出(仅输出)。 当我添加换行符时,如下所示:
rtx_report.AppendText(lclFileInfo.pathOnly + System.Environment.NewLine);
它正确地只添加一个新行。 (我从盒子里复制文本并将其粘贴到其他地方就知道这一点。 但是,在显示中,它显示一个额外的空格行。 所以我开始浏览 RichTextBox 属性,但我不确定哪个设置控制它。
看起来它只是默认为双倍行距文本,但我没有看到任何控制这一点的东西。 谁能解释一下如何让它是单倍行距的,或者不显示额外的行?
TIA,
保罗
== 编辑 ==
附言更多信息,请按 HatSoft 要求提供
lclFileInfo.pathOnly 的字符串内容是C:\用户\保罗\文档\道路
但是,所有这些代码行都会发生相同的问题:
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);
试试这个
rtx_report.AppendText(lclFileInfo.pathOnly + "r");
在 Xaml 中,将"段落"属性边距设置为零RichTextBox
。设置为 0
不会添加额外的行距。
<RichTextBox AcceptsReturn="True">
<RichTextBox.Resources>
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="0" />
</Style>
</RichTextBox.Resources>
</RichTextBox>