I found this nifty explanation here:
http://xidey.wordpress.com/2007/12/12/the-missing-drawtobitmap-function-in-the-net-webbrowser-class/"
got this function (WebBrowser.DrawToBitmap) to work.
We have to follow these points to get it working
1. The webbrowser control should not be dragged on form, Rather it should be instantiate in code.
2. The function
DrawToBitmap should only be called in
DocumentCompleted eventhandler.
Here is sample code
public partial class Form1 : Form
{
WebBrowser wb = new WebBrowser();
public Form1()
{
InitializeComponent();
wb.Height = 100;
wb.Width = 100;
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
}
void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
Bitmap bmp = new Bitmap(100, 100);
wb.DrawToBitmap(bmp, new Rectangle(wb.Location.X, wb.Location.Y, wb.Width, wb.Height));
this.pictureBox1.BackgroundImage = bmp;
}
}
"
Hope that helps.
-SB =]