65.9K
CodeProject is changing. Read more.
Home

Custom ListView class for Report Generation, Part 1

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.95/5 (10 votes)

Mar 15, 2005

viewsIcon

70522

downloadIcon

1662

A simple class generating printible reports.

Screenshot

Introduction

I've been using nashcontrol for generating reports, but had a difficult time incorporating the code into existing applications. In addition, his control does not provide the same functionality for list view controls. Nash’s control also had a drawback that it would crash for spaces in the column titles. This control is basically a wrapper for quick integration into existing code for printing listview controls.

Using the code

MyListView control is derived from System.Windows.Forms.ListView, so use it like the native ListView control. The only additional functionality is that for printing the ListView.

// call the print method for displaying the Nash’s print dialog.
this.listView1.Print();

Screenshot

Points of Interest

In the report, the column width is determined by the width of the columns in the ListView. For a detailed overview of the printing process, refer to the referenced article.

History

This is the first version, as soon as I get some time, I'll complete the tutorial.