Save the Form and other controls as Bitmap
This article represent sample code for how to Save the Form and other controls as Bitmap
Here's a simple code, which enables save the form and other control as bitmap. This is very use full for the project documentation as well as for the reports. “DrawToBitmap" method provided for all the windows controls, which is used to perform this operation. Also we are not creating any “graphics"
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
SaveAsBitmap(this,"C:\\f1.bmp");
//The same way you can pass the controls like button,dataGrid etc
//SaveAsBitmap(mydataGrid,"C:\\report.bmp")
}
public void SaveAsBitmap(Control control, string fileName)
{
//getthe instance of the graphics from the control
Graphics g = control.CreateGraphics();
//new bitmap object to save the image
Bitmap bmp = new Bitmap(control.Width, control.Height);
//Drawing control to the bitmap
control.DrawToBitmap(bmp, new Rectangle(0, 0, control.Width, control.Height));
bmp.Save(fileName);
bmp.Dispose();
}
}

I need to include in the report a graphics that I drew on one page of a tabbed control. How can I save it as bitmap? Note that the page may not be active or visible. Using the code above doesn't work in that case. Thank you.
Javier