hi,
I want my application preview before printing the txtfile. I use printpreviewdialog component but when I show it. A blank will appear. I can now print my document but i want to preview first before printing.
Popskie
Printable View
hi,
I want my application preview before printing the txtfile. I use printpreviewdialog component but when I show it. A blank will appear. I can now print my document but i want to preview first before printing.
Popskie
Just coincidently read about the control the week-end, but did not use it.
Here's what's written in the tutorial....
Using PrintPreviewControl
The .NET Framework provides a PrintPreviewControl control to allow you to graphically preview print content before it is actually sent to the printer. The PrintPreviewControl control can be found on the Windows Forms tab of the Toolbox, and you can add an instance of it by dragging it onto your form.
In order to preview a page, the PrintPreviewControl control must be associated with a PrintDocument instance. This association is created by setting the PrintPreviewControl.Document property, as follows:
Visual Basic .NET
myPrintPreview.Document = myPrintDocument
Visual C#
myPrintPreview.Document = myPrintDocument;
When this association is made, the PrintPreviewControl control will display the content that is to be printed in the control. This is accomplished by invoking the method that handles the PrintDocument.Print event and capturing the graphics output from that method. This output is then rendered in the PrintPreviewControl control.
As program conditions change, the printed document might change as well. You can update the preview by calling the InvalidatePreview method, as follows:
Visual Basic .NET
myPrintPreview.InvalidatePreview()
Visual C#
myPrintPreview.InvalidatePreview();
This causes the page displayed by the PrintPreviewControl control to be refreshed.
Another important property of the PrintPreviewControl control is the Zoom property. This specifies the magnification level at which the preview is displayed. A value of 1 causes the preview to be displayed at full size. A fractional value reduces the image, and a value greater than 1 enlarges it.
PrintPreviewDialog
The PrintPreviewControl control is a valuable resource for previewing your printed documents and creating custom previews. However, for most applications, a standard suite of print preview functionality is adequate. The .NET Framework provides a standard PrintPreviewDialog control that exposes the most commonly used print preview functionality.
You can preview a document by setting the Document property of the PrintPreviewDialog object to the PrintDocument object you want to preview. Once displayed, the PrintPreviewDialog control provides functionality to view multiple pages of the preview, to zoom, or to print the document. You can display a PrintPreviewDialog box by calling the Show or ShowDialog methods, as with any form.
If you use a PrintPreviewDialog you need to be aware that your code will execute the printing process you define to produce the preview. If the user chooses to print from the PrintPreviewDialog then your print routine will be executed a second time. This means that if you are using a variable to track the current page number then you must reset it at the end of the print routine so that the second execution will start from the beginning again.
thanks for all the idea.