Printing a form is not a good idea. Usually, a form contains some pure computer style controls: combo boxes, check boxes — you name it. When a user prints it all on paper, what can she or he click on? :-)
More reasonable approach is to separate UI and other parts of your application and have some
data layer, or some
data model which should be fundamental relative to the UI. It should have different (by perhaps similar) presentations for the form-based UI, maybe some other UI, printed version and maybe more. The usual way of printing, especially in the
System.Windows.Forms
applications is using the class
System.Drawing.Printing.PrintDocument
. Please see:
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx[
^].
You can use the basic code sample provided at the end of this article. Pay attention that the rendering is based on the instance of the class
System.Drawing.Graphics
:
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.aspx[
^].
This will allow you to use the same code for some other rendering, for example, for saving identical graphics into a bitmap. You should have a method having a
Graphics
parameter, to be used in both cases, or more.
I also would advise you to avoid VB.NET-specific libraries and use only .NET FCL (
http://en.wikipedia.org/wiki/Framework_Class_Library[
^]), as you want better compatibility and problem-free maintenance.
—SA