【发布时间】:2014-02-28 08:49:52
【问题描述】:
我有这段代码
string myText = new TextRange(mainWindow.richtextbox2.Document.ContentStart,
mainWindow.richtextbox2.Document.ContentEnd).Text;
//replace two or more consecutive spaces with a single space, and
//replace two or more consecutive newlines with a single newline.
var str = Regex.Replace(myText, @"( |\r?\n)\1+", "$1", RegexOptions.Multiline);
mainWindow.Dispatcher.Invoke(new Action(() =>
mainWindow.richtextbox2.Document.Blocks.Add(new Paragraph(new
Run("Hello")))));
这已经有效,但在发送的文本之间仍有间距。 如何修复它或更新我的富文本框?我正在尝试消除将文本显示到 Richtextbox 时的间距,如图所示
我要展示:
Hello
Hello
Hello
没有多个换行符或空格。
【问题讨论】: