views:

387

answers:

2

I am looking for best practices in regards to printing from a WinForms application.

In my particular case, I have an existing WinForms application that needs to be extended with printing functionality. The program should not just print the content on the screen, but take some of the data in the form and put it in a template and print that.

Thanks, Egil.

+3  A: 

Broadly there are two main methods of printing in .NET. The original printing api which involves a callback on a method repeatably and you setting the arguments correctly (HasMorePages) to indicate whether there are more pages to print. It is pretty much all or nothing to use this API.

The second involves the use of WPF and unlike the previous API. They have various level of complexity ranging from using a printvisual method on the elements of a WPF forms to the level of control in the regular printing API.

The third alternative, especially for WinForms, is to use Printer Compatibility Library from the VB Power Pack 3.0 from here It restores the simplicity of the older methods of Visual Basic. Despite it focus on Visual BASIC.NET it can be referenced from any .NET language.

Another alternative is use something like Crystal Reports for your printing.

RS Conley
Crystal Reports is bundled with Visual Studio and learning to use that tool gives some portability to the skillset learned.
David
+1  A: 

One option would be using .net reportViewer control and .rdlc reports...

Mr. Brownstone
While sometimes a WTF on its own, the ReportViewer reports saved a lot of work in my last project, so +1 for this answer.
OregonGhost