I'm currently testing with the HTML below. What i basicly want is to be able to render only the div element with id "test3".
<html>
<body>
<div id="test1" style="background-color:purple;">test1</div>
<div id="test2" style="background-color:red;">test2</div>
<div id="test3" style="background-color:yellow;">test3</div>
</body>
</html>
I've already tried with the code below. I retrieve the html element and render interface and draw it to an existing panel. Problem is that the whole webpage get's rendered instead of the given div element. Is there a solution for this problem. Or maybe another way to do this?
HtmlElement element = this.webBrowser1.Document.GetElementById("test3");
if (element != null) {
IHTMLElementRender render = (IHTMLElementRender)element.DomElement;
if (render != null) {
using (Graphics graphics = this.panelControl1.CreateGraphics()) {
IntPtr hdc = graphics.GetHdc();
render.DrawToDC(hdc);
}
}
}