将RichTextBox保存在WPF C#中 [英] save richtextbox in wpf c#
本文介绍了将RichTextBox保存在WPF C#中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在文本编辑器中保存包含三个Richtextbox到txt的文本?
how can I save in my texteditor that content three richtextbox to txt?
推荐答案
此控件的内容由其属性Document
定义,请参见 http://msdn.microsoft.com/en-us/library/system .windows.controls.richtextbox.document.aspx [ ^ ].
因此,要存储或加载文档,您需要使用System.Windows.Documents.FlowDocument
, ^ ].
通过此类和属性,您可以操作文档,尤其是对其进行持久化.数据的操作取决于您使用的DataTemplate
,请参见 http://msdn. microsoft.com/en-us/library/system.windows.datatemplate.aspx [ http://msdn.microsoft.com/zh-cn/library /aa970779.aspx#save_load_and_print_richtextbox_content [ ^ ].
—SA
The content of this control is defined by its propertyDocument
, see http://msdn.microsoft.com/en-us/library/system.windows.controls.richtextbox.document.aspx[^].
So, to store or load the document, you need to work with this property of the typeSystem.Windows.Documents.FlowDocument
, http://msdn.microsoft.com/en-us/library/system.windows.documents.flowdocument.aspx[^].
Through this class and property, you can manipulate the document, in particular, persist it. The manipulation of the data depends onDataTemplate
you use, see http://msdn.microsoft.com/en-us/library/system.windows.datatemplate.aspx[^].
To store and load the document, you can use the classTextRange
which you can get from your instance ofRichTextBox
. For a code sample, see: http://msdn.microsoft.com/en-us/library/aa970779.aspx#save_load_and_print_richtextbox_content[^].
—SA
这篇关于将RichTextBox保存在WPF C#中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文