Spread Windows Forms 12.0 Product Documentation
Providing a Preview of the Printing
Spread Windows Forms 12.0 Product Documentation > Developer's Guide > Managing Printing > Displaying Dialogs for Users > Providing a Preview of the Printing

You can preview what the printed pages will look like for a sheet and you can allow your end user to preview the printing.

You can use the Preview property in the PrintInfo class to preview a sheet.

The following image shows the basic Print Preview Dialog that appears on your screen.

 

Use the OwnerPrintDraw method of the FpSpread class to provide a print preview dialog with options for previewing the pages before printing.

Use the ShowPageSetupButton property of the PrintInfo class to show the PageSetUp button on the toolbar of the Print Preview Dialog. With this button, you can set the orientation (portrait and landscape) and margins etc. of the page you want to print.

Two additional printing features are: the PrintPreviewShowing event and the ability to set your own print preview dialog with the SetPrintPreview method (and the corresponding GetPrintPreview method), all members of the FpSpread class. The PrintPreviewShowing event fires prior to displaying the dialog and supplies you with both the PreviewDialog and the PreviewControl in its event parameter list so you can make on-the-fly modifications to the PrintPreviewDialog and the PrintPreviewControl objects.

The print preview dialog allows you to zoom in and out to change the scale of what you see in the preview. You can set the preview to display one, two, four, or six pages of the spreadsheet per printed page. You can print from the print preview dialog or close the dialog when done.

You can also print and preview the printing within the Spread Designer. For more information on printing and previewing in Spread Designer, refer to Printing a Sheet from Spread Designer and Previewing a Sheet in Spread Designer.

You can also customize the Print Preview settings to show the Print Preview Dialog like Excel. For more information, refer to Customizing the Print Preview Dialog.

Using Code

Set the Preview property of the PrintInfo class to true in order to allow users to preview spreadsheets and see the modifications concurrently while the settings of the printer are being changed.

Example

This example shows how to apply printer setting to show the print preview dialog.

C#
Copy Code
//Code to show the print preview dialog

fpSpread1.ActiveSheet.Cells[1, 1].Value = "1,1";
fpSpread1.ActiveSheet.Cells[10, 10].Value = "10,10";
fpSpread1.ActiveSheet.PrintInfo.Preview = true;
fpSpread1.PrintSheet(fpSpread1.ActiveSheet);
VB
Copy Code
'Code to show print preview dialog
fpSpread1.ActiveSheet.Cells(1, 1).Value = "1,1"
fpSpread1.ActiveSheet.Cells(10, 10).Value = "10,10"
fpSpread1.ActiveSheet.PrintInfo.Preview = True
fpSpread1.PrintSheet(fpSpread1.ActiveSheet)