Saturday, February 19, 2011

Is there a way to convert from System.Windows.Forms.HtmlElement to mshtml.IHTMLElemenet3?

Is there a way to convert from System.Windows.Forms.HtmlElement to mshtml.IHTMLElemenet3?

--edit after answer accepted -- This is what the code would look like.

HtmlElement myElement = getElementByID(id);
IHTMLElement3 h3 = (IHTMLElement3) myElement.DomElement;

Thanks @korchev

From stackoverflow
  • Not just by casting. The object hierarchy is completely disparate. You could write an explicit cast operator overload to do it yourself, however.

  • Just cast the DomElement property to mshtml.IHTMLElement3

0 comments:

Post a Comment