Skip to main content

Create a Custom Print Preview

  • 2 minutes to read


You need a WinForms subscription to use the API described in this tutorial.

The Invoke a Default Print Preview Form tutorial illustrates how to open the Print Preview with the Reporting subscription.

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.


If your WinForms application targets .NET Core/.NET5+, add the DevExpress.Win.Design NuGet package to this application to use the DocumentViewer control.

  1. Switch to the application’s main form in Visual Studio and press CTRL+ALT+X to open the Toolbox. Expand the DX.22.2: Reporting category and drop the DocumentViewer control onto the form.


  2. Click the Document Viewer’s smart tag and select the report in the Document Source drop-down menu to assign a report to the DocumentViewer.DocumentSource property.



    The application project should be built so that the reports it includes are available in the Document Source drop-down menu.

  3. Click the Document Viewer’s smart tag and select the Create Ribbon Toolbar or Create Standard Toolbar action to create the required toolbar.


  4. Optional. If you want to preview a large report that might consume a lot of memory, bind the DocumentViewer control to the CachedReportSource component instead. This component stores document pages in a file system or database when the document is generated and thus allows you to avoid issues related to memory consumption.

    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. Assign one of the following ready-to-use document storages to the Storage property:

    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.


  5. Optional. Enable the DirectX Hardware Acceleration. Refer to the viewer’s UseDirectXPaint property description for more information.

See Also