Printing Tabular Data

Team Fly 

Page 179

Printing Tabular Data

In this section we're going to build another custom control by adding printing capabilities to the ListView control. The ListView control is a flexible tool for displaying tabular data, but like all other built-in controls doesn't provide printing capabilities. Another limitation of the ListView control is that it can't break its contents into multiple lines when displaying data in detail mode (which is the most common mode in typical applications). Figure 7.8 shows the test form of the application and a Print Preview window with the control's data. The control's data will be printed as shown on the preview window. Notice that the long lines that don't fit in the control's cells are printed on multiple lines.

image

FIGURE 7.8 Printing tabular data with an enhanced version of the PRNListView control.

The PRNListView control exposes a single method, the Print method. The code picks up the data as well as the formatting information from the control itself and prepares the printout, which is displayed in the Preview dialog box first. The user can send the output to the printer by clicking the Print button on the dialog box's toolbar.

In addition to the Print method, the control exposes a number of properties that allow you to customize the appearance of the report. All of the enhanced control's property names start with the prefix ''Print"; they are as follows:

PrintBorderColor The color of the border around each cell.

PrintColumnPadding The extra space between columns (expressed in pixels).

PrintMaxCellLines The maximum number of lines in each cell. This property prevents a cell with a lot of text from becoming too tall. Normally, the control fits the text in its cell by breaking it into multiple lines.

Team Fly 


Visual Basic  .NET Power Tools
Visual Basic .NET Power Tools
ISBN: 0782142427
EAN: 2147483647
Year: 2003
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net