积极答复者
System.Windows.Controls.RichTextBox 类数据如何转换为System.Windows.Forms.RichTextBox 类数据

问题
答案
-
Hi zhang_nepdi,
一个是winform控件(rtf),一个是wpf的控件(flowdocument),不能直接转换的。
你可以试试下面的方法(通过io方式把它转化):
//保存
var content = new TextRange(doc.ContentStart, doc.ContentEnd); if (content.CanSave(DataFormats.Rtf)) { using (var stream = File.OpenWrite("test.rtf")) { content.Save(stream, DataFormats.Rtf); } } //读取: var content = new TextRange(doc.ContentStart, doc.ContentEnd); if (content.CanLoad(DataFormats.Rtf)) { content.Load(stream, DataFormats.Rtf); }
Regards,
Moonlight
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.
- 已编辑 Moonlight ShengMicrosoft contingent staff 2016年6月16日 6:11
- 已标记为答案 zhang_nepdi 2016年6月22日 2:06
全部回复
-
Hi zhang_nepdi,
一个是winform控件(rtf),一个是wpf的控件(flowdocument),不能直接转换的。
你可以试试下面的方法(通过io方式把它转化):
//保存
var content = new TextRange(doc.ContentStart, doc.ContentEnd); if (content.CanSave(DataFormats.Rtf)) { using (var stream = File.OpenWrite("test.rtf")) { content.Save(stream, DataFormats.Rtf); } } //读取: var content = new TextRange(doc.ContentStart, doc.ContentEnd); if (content.CanLoad(DataFormats.Rtf)) { content.Load(stream, DataFormats.Rtf); }
Regards,
Moonlight
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.
- 已编辑 Moonlight ShengMicrosoft contingent staff 2016年6月16日 6:11
- 已标记为答案 zhang_nepdi 2016年6月22日 2:06