Skip to main content

Printing

  • 3 minutes to read

The printing system allows you to print Views. This topic describes the basics of using this WinForms-specific system.

The printing system contains the PrintingController View Controller. It is activated for Detail Views and List Views. All the functionalities it represents are in the following Actions.

  • Page Setup…

    Invokes the Page Setup window, where an end-user can set up page printing options.

    PrintingModule_1

    This Action is enabled only for root Views.

  • Print Preview…

    Shows how the current View will be printed. An end-user can make changes in the prepared page; for example; add color, margins, header, footer and so on. To accomplish this, there are numerous options in the Preview window. After you are satisfied with the preview, you can print it using the File | Print menu item.

    Tutorial_EM_Lesson3_1_0

  • Print…

    Invokes the Print dialog, where an end-user can set up printing options and print the prepared page.

    PrintingModule_2

    This Action is enabled only for root Views.

All the Actions are added to the Print Action Container, which displays them as an item group in the File main menu.

PrintingModule

The PrintPreview Action is also available in nested List Views.

PrintingModule_3

The options specified in the “Page Setup” dialog and the ‘Header and Footer’ options, which are set in the Preview dialog, are saved automatically. The IModelPrintingSettings node is added to the Application Model, and filled with values each time printing settings are changed via the PageSetup or PrintPreview Actions for a View. These options can be saved separately for each View, or they can be saved to the IModelOptions to affect all Views in an application. By default, the options set for a View affect all Views. You can change this behavior via the application project designer:

PrintingSettingsStorage

The PrintingController exposes two useful public events:

The XAF printing system actually uses the XtraPrinting library to print and preview XAF Views. XtraPrinting enables printing for the controls that implement the IPrintable interface. So, if a View in an XAF application is represented by a control that supports the IPrintable interface, this View can be printed, and the printing’s Actions are enabled for this View. A Detail View’s control is a Layout Control, which is printable. So, Detail Views can be printed. List Views are represented by the controls specified by List Editors. All Windows Forms built-in List Editors support the IExportable interface, which in its turn returns a printable control via the IExportable.Printable property. So, all List Views can be printed as well. If you use a custom List Editor to display List Views, and you want its data to be printable, implement the IExportable interface in it, and the DevExpress.XtraPrinting.IPrintable interface in the control it uses. To learn how to implement the IPrintable interface in a standard control, refer to the How to: Create a Printable ListView Descendant Implementing the IPrintable Interface topic.

The printing system is demonstrated in the Feature Center Demo installed with XAF.

See Also