1. add print document to your form
2. write the code below in your printDocument_PrintPage event, i am going to print the content of panel3
3. write the code at your print button event
2. write the code below in your printDocument_PrintPage event, i am going to print the content of panel3
private void
printDocument1_PrintPage(System.Object
sender,
System.Drawing.Printing.PrintPageEventArgs
e)
{
// e.Graphics.DrawImage(memoryImage, 0, 0);
float x = e.MarginBounds.Left;
float y = e.MarginBounds.Top;
Bitmap bmp = new Bitmap(this.panel3.Width,
this.panel3.Height);
this.panel3.DrawToBitmap(bmp, new Rectangle(0, 0, this.panel3.Width, this.panel3.Height));
e.Graphics.DrawImage((Image)bmp, x,
y);
}
private void
btnPrint_Click(object sender, EventArgs e)
{
printDocument1.Print();
}
No comments:
Post a Comment