【发布时间】:2021-12-09 16:43:14
【问题描述】:
在尝试通过以下代码将 HTML 转换为 RTF 时
string html = "...."; // html content
RichTextBox rtbTemp = new RichTextBox();
WebBrowser wb = new WebBrowser();
wb.Navigate("about:blank");
wb.Document.Write(html);
wb.Document.ExecCommand("SelectAll", false, null);
wb.Document.ExecCommand("Copy", false, null);
rtbTemp.SelectAll();
rtbTemp.Paste();
这里 Document.Write(html); 和 Document.ExecCommand 出现错误 这里需要 using 来克服这个问题是新的请指导我们
例如:using System.Windows.Controls;
这里是完整代码image full
【问题讨论】:
-
"getting error here" - 阅读 How to Ask 并显示实际错误以及您尝试过的错误。
-
这里是完整代码i.stack.imgur.com/Is7MW.png
-
为什么不直接右键单击(或
Ctrl+.)错误,选择快速操作和重构并添加它建议的 using 语句? -
sir @CodeCaster 显示错误,例如:CS1061 'object' 不包含'Write' 的定义,并且找不到接受'object' 类型的第一个参数的可访问扩展方法'Write'(是您缺少 using 指令或程序集引用?)
-
现在有自己的 WebBrowser 类