Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Collapse]Build an Application
  [Expand]Choose Application UI
   Data Management Controls
  [Collapse]Printing and Exporting
    How to: Preview XtraGrid Control
    How to: Customize Print Appearances
    How to: Set Paper Format and Add Custom Information to the Report when Printing/Exporting a Control
    Printing Basics
    Printing Options
    Print Appearances
    Export a Control in Various Formats (PDF, HTML, BMP, etc.) Using the XtraPrinting Library
  [Expand]WinForms MVVM
  [Expand]Skins
  [Expand]Localization
  [Expand]Right-to-Left Layout
   Redistribution and Deployment
 [Expand]Controls and Libraries
 [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

How to: Set Paper Format and Add Custom Information to the Report when Printing/Exporting a Control

This tutorial describes how to customize the paper format, orientation, and add custom information to a report. The following approach is applicable to DevExpress WinForms .NET controls that implement the IPrintable interface (e.g. XtraGrid, XtraPivotGrid, XtraScheduler, XtraTreeList, XtraCharts, Layout Control, XtraVerticalGrid etc.).

The document consists of the following sections.

To get started with this tutorial, start Microsoft Visual Studio and create a new Windows Forms Application or open an existing one. Then, run the Toolbox and drop the required control, implementing the IPrintable interface onto the form.

After that, you can provide the control with a data source or populate it manually.

Expanded Customize the Print Options at Runtime

The IPrintable interface allows you to customize printing settings and print a control using a PrintableComponentLink. The following code demonstrates how to create a PrintableComponentLink, assign a control to its PrintableComponentLinkBase.Component property, adjust its printing settings, and print the control.

Expanded Add Custom Information to a Report at Runtime

To add custom information to a report, you can create a report header or a report footer. To add a report header, subscribe to the CreateReportHeader event as shown below.

Write the CreateReportHeader event handler which has been generated, as follows.

The following image illustrates a report generated using the written code for the sample Grid Control. This report contains custom print options and additional custom information.

Expanded Export a Report to the Specified Format at Runtime

Besides exporting using the Preview window, a report can be exported through the PrintableComponentLink object. The following code demonstrates how to save the current report in a PDF file using the LinkBase.ExportToPdf method.

Expanded See Also

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