Create a Custom Print Preview
- 2 minutes to read
You need a WinForms subscription to use the API described in this tutorial.
You can implement a custom Print Preview form in your WinForms application. This tutorial demonstrates how to do this using the DocumentViewer control and binding it to a report.
Switch to the application's main form in Visual Studio and press CTRL+ALT+X to open the Toolbox. Expand the DX.20.2: Reporting category and drop the DocumentViewer control onto the form.
The application project should be built so that the reports it includes are available in the Document Source drop-down menu.
(optional) If a report is large and previewing it consumes a lot of memory, bind the DocumentViewer control to the CachedReportSource component instead. This component allows you to avoid memory consumption-related issues by storing pages in a file system or database during document generation.
Check the Cache Document Source option in the Document Viewer's smart tag after setting the Document Source property:
This adds the CachedReportSource component to the form. You can now change the component’s settings. Choose one of the following ready-to-use document storages the Storage property provides:
Allows you to compactly store a document in memory.
Allows you to store a document as a set of files in the specified directory.
Allows you to store a document in a database.