Reports for WinForms | ComponentOne
In This Topic
    Printing Reports
    In This Topic

    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:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    ' Load report definition
    c1r.Load(reportFile, reportName)
     
    ' Get PrintDocument object
    PrintDocument doc = c1r
     
    ' 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()
    

    To write code in C#

    C#
    Copy Code
    // Load report definition
    c1r.Load(reportFile, reportName);
     
    // Get PrintDocument object
    PrintDocument doc = c1r;
     
    // 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();