【问题标题】:How to clear Content of WebBrowser control using as HTML Editor?如何使用 HTML 编辑器清除 WebBrowser 控件的内容?
【发布时间】:2019-05-20 09:30:44
【问题描述】:

当我使用 HTML 编辑器 (WebBrowser) 一次保存文本后再次打开它时,它包含旧的书面内容。如何清理内容?

我尝试将文档内容(例如在加载数据库条目时)设置为HTMLEditor.Document.Write("");,但它不起作用。

所以我将包含 WebControl 的表单加载为 FrameEditor viewer = new FrameEditor(); 但它没有帮助。

我试图 set _doc = null; _doc 是 IHTMLDocument2 和 _doc = modernHTMLEditor.Document.DomDocument as IHTMLDocument2;

我尝试将 HTMLEditor 重新加载为 HTMLEditor = new WebBrowser();

private IHTMLDocument2 _doc;

private void viewer_Load(object sender, EventArgs e)
{
_doc = null;                                    
modernHTMLEditor.DocumentText = "<html><body></body></html>";
_doc =
modernHTMLEditor.Document.DomDocument as IHTMLDocument2;
modernHTMLEditor.Document.Write(DocText);
_doc.designMode = "On";
modernHTMLEditor.Document.ExecCommand("FontName", false, "Arial");
FontSizeSetup();
FontTypeSetup();
}

【问题讨论】:

    标签: c# winforms


    【解决方案1】:

    我找到了答案。 它的用途是: _doc.open(""); 在声明 designMode = "On" 之前;

    【讨论】:

    • 但我建议使用 GeckoFX 或 CefSharp 并实现 Summernote(以及它的 Jquery 和 Bootstrap)或类似的东西。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-05
    • 2019-07-14
    相关资源
    最近更新 更多