Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [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]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Collapse]Printing-Exporting
   [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]Concepts
   [Expand]Examples
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

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.

Show Me

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 2010, 2012, 2013, 2015 or 2017.

  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.17.1: 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

How would you rate this topic?​​​​​​​