C# 在处理过程中,没有文本写入RichTextBox
我有一个RichTextBox,我只想在那里写一些信息C# 在处理过程中,没有文本写入RichTextBox,c#,wpf,richtextbox,dispatcher,C#,Wpf,Richtextbox,Dispatcher,我有一个RichTextBox,我只想在那里写一些信息 FlowDocument _content = new FlowDocument(); this.Dispatcher.Invoke(() => { _content.Blocks.Add(new Paragraph(new Run("START READING FROM FILE..."))); }); //Code that reads data from an Excel file... this.Dispatc
FlowDocument _content = new FlowDocument();
this.Dispatcher.Invoke(() =>
{
_content.Blocks.Add(new Paragraph(new Run("START READING FROM FILE...")));
});
//Code that reads data from an Excel file...
this.Dispatcher.Invoke(() =>
{
_content.Blocks.Add(new Paragraph(new Run("END READING FROM FILE...")));
});
但是开始文本永远不会写入RichTextBox。它正在读取Excel文件,但没有将这些文本写入RichTextBox
我尝试了在网站上找到的几种方法,但在过程中无法将文本输入到RichTextBox。将RichTextBox的文档属性设置为“内容”。那么您的示例就可以运行了。您是否将theRichTextBox的文档属性设置为“内容”?那么你的例子就行了。@mm8是的,我确实忘了将文档设置为_content,它现在就行了。非常感谢。