【问题标题】:how to convert windows forms browser control's document object to mshtml.IHTMLDocument2如何将 Windows 窗体浏览器控件的文档对象转换为 mshtml.IHTMLDocument2
【发布时间】:2011-03-05 02:13:05
【问题描述】:

试图让这条线工作

 mshtml.IHTMLDocument2 doc2 = webBrowser1.Document as mshtml.IHTMLDocument2;

但收到错误消息

错误 10 无法通过引用转换、装箱转换、拆箱转换、包装转换或空类型转换将类型“System.Windows.Forms.HtmlDocument”转换为“mshtml.IHTMLDocument2”

这是我以前没有遇到过的。我做了一些搜索,似乎很多其他人已经让这条线工作了?非常感谢任何帮助/解释!谢谢!

【问题讨论】:

    标签: c# winforms webbrowser-control


    【解决方案1】:

    尝试以下方法:

    MSHTML.IHTMLDocument2 currentDoc =
        (MSHTML.IHTMLDocument2)webBrowser1.Document.DomDocument;
    

    我在网上找到了参考: HtmlDocument.DomDocument - at MSDN

    【讨论】:

    • 我有同样的问题,但我在 MSHTML.IHTMLDocument2 中没有 'Document.DomDocument' 属性...有什么想法吗? Tnx
    猜你喜欢
    • 1970-01-01
    • 2011-06-16
    • 2017-04-18
    • 2012-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多