Article ID: 178076 - Last Review: July 13, 2004 - Revision: 2.1 How To Use a PictureBox to Control Orientation Printing a FormThis article was previously published under Q178076 On This PageSUMMARY
When using the PrintForm method to print a Form, you have no control over
the orientation. This article describes a way to use a PictureBox to print
the client area of a Form in either orientation.
MORE INFORMATION
The PrintForm method creates its own Device Context and therefore ignores
any Printer object settings. It will just use the default orientation of
the current default printer. Because you cannot change how PrintForm
behaves, you must print another way. You could change printer settings
with APIs, print the Form, then change them back, but a simpler approach is
to print from a PictureBox. The drawback to this method of using
PictureBoxes is that you are printing a Bitmap graphic, so the quality is
less than the PrintForm methods. The process described here uses two
PictureBoxes, each one covering the Form. The second PictureBox is to avoid
a shadowing effect caused by a small offset of the redraw on a single
PictureBox. This same technique can be used to print any group of controls
or to print the client area of a Form that is larger than the screen. It also allows you to print text or other images onto the same page as the form's (PictureBox's) image.
Example of Using a PictureBox to Print a Form in Any Orientation
REFERENCES
If you need to print more than just the client area of a Form or if you
need to scale the printout, please see the following article in the
Microsoft Knowledge Base:
161299
(http://support.microsoft.com/kb/161299/EN-US/
)
How To Capture and Print the Screen, a Form, or Any Window
For more information, please see the following articles in the Microsoft Knowledge Base:
230502
(http://support.microsoft.com/kb/230502/EN-US/
)
How To Print a Form That is Too Large for the Screen or Page 194580 (http://support.microsoft.com/kb/194580/EN-US/ ) How To Print a Composite Image From a RichTextBox 146022 (http://support.microsoft.com/kb/146022/EN-US/ ) How To Set Up the RichTextBox Control for WYSIWYG Printing 242483 (http://support.microsoft.com/kb/242483/EN-US/ ) BUG: Error 486 or 482 Occurs When Using PrintForm 198901 (http://support.microsoft.com/kb/198901/EN-US/ ) SAMPLE: PageSet.exe Programmatically Changes Default Printer Orientation APPLIES TO
| Article Translations
|

Back to the top
