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
   [Expand]Getting Started
   [Expand]Fundamental Concepts
   [Expand]Concepts
   [Collapse]Examples
    [Expand]Print Preview
    [Expand]Using Bricks
    [Collapse]Using Printing Links
      How to: Print a DataGrid Control
      How to: Print a TreeView Control
      How to: Combine Links via the CompositeLink
      How to: Use Link Events (Introduction)
      How to: Use Link Events (Complete Sample)
      How to: Create a Custom Link to Print a ListView Control
      How to: Create a Printable ListView Descendant Implementing the IPrintable Interface
    [Expand]Page Header and Footer
    [Expand]Printing DevExpress Controls
    [Expand]Exporting
    [Expand]Miscellaneous
  [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

How to: Create a Printable ListView Descendant Implementing the IPrintable Interface

The following example demonstrates how a standard control can be modified to enable its use with the PrintableComponentLink. To accomplish this, the control should implement the IPrintable interface. In this topic, we create a printable descendant of the System.Windows.Forms.ListView control, that implements the IPrintable interface.

Show Me

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

This tutorial consists of the following steps:

Expanded Base Declaration

The class declaration and variable definitions are as follows:

Expanded Interfaces Implementation

It is necessary to provide the methods of the IBasePrintable interface. The new control must be initialized. The code also defines which image view, and which image list are used.

The following code implements the IBasePrintable interface, which is the base interface for the IPrintable. It defines the procedures for printing initialization, page area creation and printing completion.

Then, we have to provide methods for invoking and using the Printable Component Property Editor form and the corresponding help system.

The following code contains procedures which define and invoke the printable component Property Editor form and help system.

Expanded Drawing Methods

The code for drawing the bricks.

The following code implements methods for drawing bricks. The ps variable represents the current PrintingSystem. The IBrick.SetProperties method is used to specify the brick properties via the IBrick interface.

And, the code for the main method of report generation, which creates the report's contents.

The following code implements the CreateDetail method for the printable descendant of the System.Windows.Forms.ListView control. It populates the detail section of a report with data obtained from the control.

It calls the CreateDetails method, if the printable ListView control is in Detail mode. The code for other modes is omitted to shorten and simplify the example.

The brickGraph variable represents the IBrickGraphics interface. The code draws TextBrick objects for text items in the List View and ImageBrick objects for list view icons. Brick properties are accessed via the IBrick.SetProperties method provided by the IBrick interface.

In order to print the date and page number at the bottom of each page, the code for the page footer generation should be added.

The following code implements the CreatePageFooter method, which is used to generate a report's page footer. The resulting MarginalFooter is shown in the picture.

The next step is to create the detail header. This section is repeated on each page, and is similar to the table header. In this implementation, it is drawn only if the list view is equal to the System.Windows.Forms.View.Details.

The following code constructs a header for the report's detail area. It contains column headings for the list of items, representing the Detail view mode of the ListView control.

Expanded Get the Result

And, that's all! Finally, the control, which can be printed via the XtraPrinting Library, is created.

The original ListView control and a report, generated via the XtraPrinting Library, are illustrated below.

Expanded See Also

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