Cách in 1 form qua máy in:

1. Cho vào chương trình component: Print Document
2. Dùng hàm mẫu sau:

Code:

private void printFormToPrinter()
{
PrintDialog printDialog1 = new PrintDialog();
printDialog1.Document = printDocument1;
DialogResult result = printDialog1.ShowDialog();
if ( result == DialogResult.OK )
printDocument1.Print();
}

3. Vẽ form khi ra máy in:

Code:

using System.Drawing.Printing;

private void printDocument1_PrintPage( object sender, PrintPageEventArgs e)
{
Graphics graphic = CreateGraphics();
Image memImage = new Bitmap( Size.Width, Size.Height, graphic );
Graphics memGraphic = Graphics.FromImage( memImage );
IntPtr dc1 = graphic.GetHdc();
IntPtr dc2 = memGraphic.GetHdc();
BitBlt( dc2, 0, 0, ClientRectangle.Width,
ClientRectangle.Height, dc1, 0, 0, 13369376 );
graphic.ReleaseHdc( dc1 );
memGraphic.ReleaseHdc( dc2 );
e.Graphics.DrawImage( memImage, 0, 0 );
}