To print a report directly to the printer, use the C1Report.Document property. This property returns a standard PrintDocument object that has a Print method and exposes printer and page settings.

For example, the following code shows a print dialog and prints the report:

      Visual Basic

' Load report definition

c1r.Load(reportFile, reportName)

 

' Get PrintDocument object

PrintDocument doc = c1r.Document

 

' Show a PrintDialog so user can customize the printing

Dim pd As PrintDialog = New PrintDialog()

 

' Use PrinterSettings in report document

pd.PrinterSettings = doc.PrinterSettings

 

' Show the dialog and print the report

If pd.ShowDialog() = DialogResult.OK Then

       doc.Print()

End If

 

' Cleanup and release PrintDialog resources

pd.Dispose()

      C#

// Load report definition

c1r.Load(reportFile, reportName);

 

// Get PrintDocument object

PrintDocument doc = c1r.Document;

 

// Show a PrintDialog so user can customize the printing

PrintDialog pd = new PrintDialog();

 

// Use PrinterSettings in report document

pd.PrinterSettings = doc.PrinterSettings;

 

// Show the dialog and print the report

if (pd.ShowDialog() == DialogResult.OK)

doc.Print();

 

// Cleanup and release PrintDialog resources

pd.Dispose();


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.