please give me the code to see the print preview of the form...i used the following code but the result is it displays a dialogbox of print preview but it says the "document has no pages"..i dnt want to preview pages as the form has no pages..my form has textboxes,labels,buttons..i want to print that form exactly and need to see the preview..help... the code i used is...


private Bitmap memoryImage;
private void CaptureScreen()
{
Graphics mygraphics = this.CreateGraphics();
Size s = this.Size;
memoryImage = new Bitmap(s.Width, s.Height,
mygraphics);
Graphics memoryGraphics = Graphics.FromImage(
memoryImage);
IntPtr dc1 = mygraphics.GetHdc();
IntPtr dc2 = memoryGraphics.GetHdc();
BitBlt(dc2, 0, 0, this.ClientRectangle.Width,
this.ClientRectangle.Height, dc1, 0, 0,
13369376);
mygraphics.ReleaseHdc(dc1);
memoryGraphics.ReleaseHdc(dc2);
}
private void printDocument1_PrintPage(System.Object
sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(memoryImage, 0, 0);
}
private void printButton_Click(System.Object sender,
System.EventArgs e)
{
CaptureScreen();
printPreviewDialog1.Show();
}