SAP Knowledge Base Article - Public

1278939 - The printer set at runtime is not selected in the Crystal Reports for Visual Studio .NET viewer's print dialog

Symptom

  • The printer set at runtime is not passed to the print dialog shown by clicking the print button in CrystalReportsViewer
  • Default printer in the local machine is always selected

Environment

  • Crystal Reports XI
  • Crystal Reports XI Release 2
  • Crystal Reports 2008
  • Microsoft Visual Studio .NET 2003
  • Microsoft Visual Studio 2005

Reproducing the Issue

  1. Use the following code to set the printer at runtime before viewing the report.

          Visual Basic .NET sample code:

          crReportDocument.PrinterOptions.PrinterName = "name of printer"

  1. Run the application to display the report in CrystalReportsViewer.
  2. Click the print button in the viewer.

 

Cause

This behaviour is by design.

Resolution

Workaround: Use PrintToPrinter method to print the report.

Visual Basic .NET sample code for CR XI:

crReportDocument.PrinterOptions.PrinterName = "name of printer"

crReportDocument.PrintToPrinter(1, True, 1, 1)

C# sample code for CR 2008:

myRep.PrintOptions.PrinterName = "name of non default printer ""
System.Drawing.Printing.PageSettings mypage = new System.Drawing.Printing.PageSettings();
System.Drawing.Printing.PrinterSettings myprinter = new System.Drawing.Printing.PrinterSettings();
myprinter.PrinterName = myRep.PrintOptions.PrinterName;
myRep.PrintToPrinter(myprinter, mypage, false);

Keywords

CR for .NET, Crystal Reports, VS.NET, printer, dialog box, default , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

SAP Crystal Reports XI ; SAP Crystal Reports XI R2