Let's first look at the form; see the following image :

Now the code:
In the form there are two options. First one is to print the whole form & the other one is to print the picture.
Let us see first how to print the picture.
First of all we have to create an object of Bitmap & its size is as picturebox width & height.
- Bitmap myBitmap1 = new Bitmap(myPicturebox.Width, myPicturebox.Height);
- myPicturebox.DrawToBitmap(myBitmap1, new Rectangle(0, 0, myPicturebox.Width, myPicturebox.Height));
- e.Graphics.DrawImage(myBitmap1, 0, 0);
Now create the objects of the PrintDocument & PrintDialog.
- System.Drawing.Printing.PrintDocument myPrintDocument1 = new System.Drawing.Printing.PrintDocument();
- PrintDialog myPrinDialog1 = new PrintDialog();
- myPrintDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(myPrintDocument2_PrintPage);
- myPrinDialog1.Document = myPrintDocument1;
- if (myPrinDialog1.ShowDialog() == DialogResult.OK)
- {
- myPrintDocument1.Print();
- }
The above code will ask you the printer name in which you can print the picture.
The full code for printing the picture.
- private void myPrintDocument2_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e)
- {
- Bitmap myBitmap1 = new Bitmap(myPicturebox.Width, myPicturebox.Height);
- myPicturebox.DrawToBitmap(myBitmap1, new Rectangle(0, 0, myPicturebox.Width, myPicturebox.Height));
- e.Graphics.DrawImage(myBitmap1, 0, 0);
- myBitmap1.Dispose();
- }
- private void btnPrintPicture_Click(object sender, EventArgs e)
- {
- System.Drawing.Printing.PrintDocument myPrintDocument1 = new System.Drawing.Printing.PrintDocument();
- PrintDialog myPrinDialog1 = new PrintDialog();
- myPrintDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(myPrintDocument2_PrintPage);
- myPrinDialog1.Document = myPrintDocument1;
- if (myPrinDialog1.ShowDialog() == DialogResult.OK)
- {
- myPrintDocument1.Print();
- }
- }



The same code will be used for the whole form but instead of the pictureboc object it will use this & using the width & height, it will print the whole form.
The whole code for printing the form:
- private void myPrintDocument1_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e)
- {
- Bitmap myBitmap2 = new Bitmap(this.Width, this.Height);
- this.DrawToBitmap(myBitmap2, new Rectangle(0, 0, this.Width, this.Height));
- e.Graphics.DrawImage(myBitmap2, 0, 0);
- myBitmap2.Dispose();
- }
- private void btnPrintForm_Click(object sender, EventArgs e)
- {
- System.Drawing.Printing.PrintDocument myPrintDocument2 = new System.Drawing.Printing.PrintDocument();
- PrintDialog myPrinDialog2 = new PrintDialog();
- myPrintDocument2.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(myPrintDocument1_PrintPage);
- myPrinDialog2.Document = myPrintDocument2;
- if (myPrinDialog2.ShowDialog() == DialogResult.OK)
- {
- myPrintDocument2.Print();
- }
- }

Hope this is clear to all of you….

ferman kanebiPosted Mar 21, 2018, 6:42 AM
Thank you very much
nick KurPosted Jan 13, 2017, 1:32 PM
Hi, thank you very much for your code, it works very well for me. Just have one question. When my form prints to a page it is using about 3/4 of the A4 paper. What changes can I make so the form stretches to all paper field? Thank you.
Tiziano FortinPosted Jan 13, 2016, 4:58 PM
I'm an absolute beginner. Your program works very well also in my pc, but if I add some text boxes they don't appear in the printing. My idea is to obtain a fillable form. Can you help me? Kind regards.
Rohit VermaPosted Jun 8, 2015, 2:20 AM
Thanks A Lot for easy code......Searched a lot for this code and none other than this site provided me the correct and easy way of printing.
Ajit MorePosted Mar 13, 2015, 12:00 AM
How To Print Multiple Picturebox images on Separate pages......
ashish kumarPosted Oct 19, 2014, 4:35 AM
Really liked you code, and the way of simple illustration and implementation.
Ghanashyam NayakPosted May 21, 2012, 7:08 AM
Hi Radhakrishnan G, Thank you. it is good to see that article is useful for you...
rikin shahPosted May 12, 2012, 2:26 PM
Hello, I need your kind help. I have 1 task in Printing a winform's values. Client has given already printed paper with blank value. these values i need to fill in paper while printing. Pls give me code that can print only values at specific locations. that would be better if this can be possible directly from Current form or using Report Viewer. pls help me in this with code.
Radhakrishnan GPosted May 3, 2012, 8:11 AM
Very Nice Illustration and a very usefull article. I was searching to make a export functionality to print the drawing entities in GDI to a image file. Now studying this article i have done it. Thank you..
Rais ShaikhPosted Mar 26, 2012, 1:26 PM
Thanks Sir
Abhi KumarPosted Feb 14, 2012, 11:30 PM
Very useful article. Thanks for sharing.
Adora KrausePosted Feb 14, 2012, 11:05 PM
Hi. You have presented your article so nicely that anyone will love to read this.
Nitin SinghPosted Feb 14, 2012, 10:42 PM
Really thanks for this article.