[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
   [Expand]Product Information
   [Collapse]Getting Started
     Lesson 1 - Show the Print Preview for a Link
     Lesson 2 - Draw Simple Text
     Lesson 3 - Draw Formatted Text
     Lesson 4 - Draw Formatted/Colored Text
     Lesson 5 - Insert Two Bricks
     Lesson 6 - Insert Two Rows
     Lesson 7 - Insert Two Rows and Three Columns
     Lesson 8 - Insert Three Rows and Three Columns
     Lesson 9 - Create a Multi-Page Document
   [Expand]Fundamental Concepts
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Lesson 1 - Show the Print Preview for a Link

This lesson illustrates how to create a basic printing link that creates an empty document, and how to create a Print Preview in a Windows Forms Application to show this document.


A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E161.

To create a Print Preview and show a document in it, do the following.

  1. Create a new Windows Forms Application in Visual Studio 2012, 2013, 2015, 2017 or 2019.
  2. To add a print preview to your application, switch to the application's main form in Visual Studio, and press CTRL+ALT+X to run the Toolbox. Expand the DX.19.2: Reporting category and drop the DocumentViewer control onto the form.

  3. Click the smart tag of the control, and in the invoked actions list, select a toolbar that matches the user interface style of the rest of your application. In this tutorial, the ribbon toolbar is preferred over the minimal bar interface.

  4. To assign a document source to the control, click its smart tag again. In the drop-down menu of the DocumentViewer.DocumentSource property, expand the Standard Sources category and select PrintingSystem.

  5. Press F7 to switch to the code view, and declare a new public class (called Lesson1), inherited from the Link class.

    Each subsequent lesson will create a class derived from the class created in the preceding lesson. Calling the Link.CreateDocument method will generate a document after making changes to it in code.

  6. Handle the main form's Load event and add the following code to the event handler.

    In this code, the Printing System of the Document Viewer is passed, and assigned to the created printing link.

Launch the application and view the result.

Expanded See Also

Is this topic helpful?​​​​​​​