The dbicList control is capable of producing a print preview and a printed report through its PrintPreview and Print methods respectively. The data presented in the report is based upon the PrintReportType property which can be set to print only those items which are currently visible in the control (Dbi.WinControl.enumPrintReportType.Current), the current page in the control (Dbi.WinControl.enumPrintReportType.Page ), or all of the items in the control. The ability to identify dbiNodeItems as headers (footers)allows the developer to programmatically generate groupings and sub-totals as the list is being populated. DbiNodeItem level detail for formatting (font, color) provides the developer with fine-grained control over the presentation of groups and group-level items.
The following properties can be used to customize the output of the dbicList Print and PrintPreview methods:
|
Property |
Type |
Description |
|
System.Drawing.Color |
Determines the background color of the header in a printed report. |
|
|
System.Drawing.Color |
Determines the text color of the header in a printed report. |
|
|
System.Drawing.Color |
Determines the background color of the item in a printed report. |
|
|
System.Drawing.Color |
Determines the text color of the item in a printed report. |
|
|
Dbi.WinControl.enumPrintListFormat |
Determines the type of printed report to produce. |
|
|
Dbi.enumBorderType |
Determines the type of border to place around the printed report. |
|
|
Boolean |
A value indicating if the page should be printed as rendered in the form or using the Print properties set in the control. |
|
|
Boolean |
Determines whether or not the footer will be printed. |
|
|
System.Drawing.ContentAlignment |
Determines the alignment for the footer in a report. |
|
|
System.Drawing.Font |
Determines the font for the footer in a report. |
|
|
Dbi.WinControl.List.dbiPageSettings |
Determines the page setup for the printed report. |
|
|
Boolean |
Determines whether or not the page sub-title will be printed. |
|
|
System.Drawing.ContentAlignment |
Determines the alignment for the sub-title in a printed report. |
|
|
System.Drawing.Font |
Determines the font for the sub-title in a printed report. |
|
|
String |
Determines the text for the sub-title in a printed report. |
|
|
String |
Determines the text describing the page number in the footer of a printed report. |
|
|
Boolean |
Determines whether or not the page title will be printed. |
|
|
System.Drawing.ContentAlignment |
Determines the alignment for the title in a printed report. |
|
|
System.Drawing.Font |
Determines the font for the title in a printed report. |
|
|
String |
Determines the text for the title in a printed report. |
|
|
Dbi.WinControl.enumPrintReportType |
Determines the scope of the printed report (Current, Full, Page). |
|
|
System.Drawing.Color |
Determines the background color of the title in a printed report. |
|
|
System.Drawing.Color |
Determines the text color of the title in a printed report. |
The dbicList Print and PrintPreview methods require the layout characteristics of the target printer in order to format the output. Accordingly, the Print and PrintPreview methods will prompt the user for the target printer in order to obtain a handle for the printer to query it for its paper size and orientation. To further adjust the output the developer can use the properties of the PrintPageSettings to set the document format of the report prior to printing.
Adding Page Breaks to a report
The dbiNodeItem class includes a PageBreak property that when set to true forces a page break and causes the item to print on a new page. The following example illustrates how to include a page break when a total line is added to the dbicList control …
Example:
VB.NET
Private Function PrintTotal(ByVal strTotal2Print As String, ByVal intTotal2Print As Integer) As Integer
'Creates a total line item for a make in the Automobile Inventory report
Dim MakeTotalItem As New Dbi.WinControl.dbiNodeItem 'Create a new dbiNodeItem
MakeTotalItem.Text = strTotal2Print + Format(intTotal2Print, "0") 'Set the new item's text
'NOTE: Header items do not adhere to the column formatting and become freeform text.
MakeTotalItem.Header = True 'Make the new item a header.
'NOTE: To cause the list to perform a page eject after a footer (total) use the
‘PageBreak property in the dbiNodeItem
MakeTotalItem.PageBreak = True
Me.dbicListReports.Items.Add(MakeTotalItem) 'Add the new item to the list
Me.dbicListReports.Items.Add("") 'Add a blank line to the list.
Return 0 'Resets the Total
End Function
C#
private int PrintTotal(String strTotal2Print, int intTotal2Print)
{
// Creates a total line item for a make in the Automobile Inventory report
// Create a new dbiNodeItem
Dbi.WinControl.dbiNodeItem MakeTotalItem = new Dbi.WinControl.dbiNodeItem();
// Set the new item's text
MakeTotalItem.Text = strTotal2Print + String.Format(intTotal2Print.ToString(), "0");
// Make the new item a header.
// NOTE: Header items do not adhere to the column formatting and become freeform text.
MakeTotalItem.Header = true;
// NOTE: To cause the list to perform a page eject after a footer (total) use the PageBreak property in the dbiNodeItem
MakeTotalItem.PageBreak = true;
// Add the new item to the list
this.dbicListReports.Items.Add(MakeTotalItem);
// Add a blank line to the list.
this.dbicListReports.Items.Add("");
return 0; // Resets the MakeTotal
}