MindFusion WinForms Programmer's Guide
Printing and Print Previewing

Printing

To print the report, you need an instance of the ReportPrinter class. Assign the report to be printed to the Report property of the ReportPrinter object then call its Print method. Make sure that the attached report has been previously processed by a call to its Run method.

The following example demonstrates the use of the ReportPrinter class. The example assumes that report1 is a variable identifying a valid Report instance and that the Run method of this instance has already been invoked.

C#  Copy Code

ReportPrinter printer = new ReportPrinter();
printer.Report = report1;
printer.Print();

Visual Basic  Copy Code

Dim printer As New ReportPrinter()
printer.Report = report1
printer.Print()

Previewing

To preview the report, create a ReportPrinter object and assign the report to its Report property in a way similar to the one specified above. Instead of calling the Print method however, create an instance of the .NET PrintPreviewDialog class, assign the previously created ReportPrinter object to its Document property and call its Show or ShowDialog method.

The following example demonstrates how to preview an existing report. The example makes the same assumptions as the one above.

C#  Copy Code

ReportPrinter printer = new ReportPrinter();
printer.Report = report1;

PrintePreviewDialog previewDialog = new PrintePreviewDialog();
previewDialog.Document = printer;
previewDialog.ShowDialog();

Visual Basic  Copy Code

Dim printer As New ReportPrinter()
printer.Report = report1

Dim previewDialog As New PrintePreviewDialog()
previewDialog.Document = printer
previewDialog.ShowDialog()

Using the extended Print Preview form

MindFusion.Reporting supplies a custom print preview form. This form contains better looking toolbar icons but its functionality is similar to the standard PrintPreviewDialog. The extended preview form is exposed by the PrintPreviewForm class, found in the MindFusion.Reporting.WinForms.dll. The extended form is used the same way as the standard .NET PrintPreviewDialog - you assign the ReportPrinter object to its Document property and call either Show or ShowDialog methods.

The following image shows the extended preview form displaying a report:

The extended preview form can be customized through the options argument supplied to its overloaded constructor. This argument is of type PreviewOptions and provide several properties that allow you to customize various aspect of the form, such as the tooltips of the toolbar buttons.