Click here to Skip to main content
15,923,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the following code to print a form.
C#
PaperSize pp = new PaperSize("MyReport", 827, 1169);
printForm1.PrinterSettings.DefaultPageSettings.PaperSize = pp;
printForm1.PrinterSettings.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
printForm1.PrintAction = System.Drawing.Printing.PrintAction.PrintToPreview;
printForm1.Print(this, PrintForm.PrintOption.FullWindow);

with references
C#
using Microsoft.VisualBasic.PowerPacks.Printing;
using System.Drawing.Printing;
using System.Runtime.InteropServices;

It's work fine and print a blank form. but I need to print a form named printForm.cs which i already designed into my project. How can I solve this? I am new in printing, please help me. Thank's in advance.
Posted

1 solution

Don't do that!

Instead, look at using the PrintDocument Class[^] - it gives you a lot greater flexibility and a better print out.
It may seem more work that just dumping controls on a page, but it is worth it - teh results are a lot better.

The link includes an example.
 
Share this answer
 

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