Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.33/5 (3 votes)
See more:
Can I send complete windows form to printer to print with all its contents (controls with text and images) displaying on screen? If yes, please provide code for it.
Posted
Updated 23-Feb-11 8:42am
v2

 
Share this answer
 
Comments
JF2015 24-Feb-11 0:26am    
Good answer 5+
Espen Harlinn 25-Feb-11 6:59am    
Agree, my 5
Hi,

Preraks answer is very good, but the CP article has some limitations about the controls that can be printed. Just to add one simple way. You can create a bitmap from any control (e.g. your form) by using this code:
Bitmap bmp = new Bitmap(this.Width, this.Height);
this.DrawToBitmap(bmp, Rectangle.FromLTRB(0, 0, this.Width, this.Height));
//bmp.Save("C:\\Test.bmp"); // save it to a file or send it to the printer

After creating the bitmap you can do anything you want with it - so it should be quite easy to send it to the printer.
I hope it helps!
 
Share this answer
 
Comments
Espen Harlinn 25-Feb-11 7:00am    
Nice addition, my 5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900