Skip to Content
avatar image
Former Member

Change default printer in CrystalReportViewer

I'm using CR XI Release 2 and Visual Studion 2005.

I want to print out the report from the preview window. Is it possible to set the default printer in the print dialog?

I changed the property PrintOptions.PrinterName of the ReportDocument, but it have no affect to the presetting of the print dialog.

Have anyone an idea?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Mar 18, 2009 at 01:23 PM

    Hi,

    Try with this:

    crReportDocument.PrintOptions.PrinterName ="\\ " ;
    crReportDocument.PrintToPrinter(1, true, 1, 1);
    

    We can set default Printer from Crystal Report design:

    Go to File-> Page Setup.

    Or if you are printing through code set the No Printer option in Crystal Report Designer

    In Reports designer. Go to File|Page Setup and set the printer to "No Printer". Save the report.

    You can download samples from [here|https://www.sdn.sap.com/irj/boc/samples]

    Regards,

    Shweta

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Shweta,

      thank you very much for your answer.

      But I don't output the report by calling PrintToPrinter.

      First I output the report to a window by using the class CrystalReportViewer.

      Then I click the print-button in the preview window and the print dialog appears.

      In this print dialog you can choose the printer in a combobox.

      And my requirement is: To preset the printer in the print dialog.

      Regards

      Andreas

  • avatar image
    Former Member
    Mar 18, 2009 at 11:59 PM

    Hi Andreas,

    From the description, if I can understand correctly, you are previewing the report within Visual Studio itself (by clicking Main Report Preview tab). Am I correct ?

    If thats true, then you will need to set the default printer from the Control Panel | Printers options.

    Just previewing the report in the visual studio will not be calling the printer code; unless you build and run the application and then try to print.

    Hope it helps !

    Ranjeet

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 18, 2009 at 01:26 PM

    Hi

    Try this code -

    boReportDocument.PrintOptions.PrinterName = "\\NetworkName\PrinterName" 
    
    'Send to Printer 
    boReportDocument.PrintToPrinter(False, 0, 1, 1) 
    'CrystalReportViewer1.ReportSource = boReportDocument
    
    'MessageBox("Registration Form is printed on PrinterName Printer") 
    Else 
    MessageBox("Check Printer settings") 
    End If 
    

    Also open the report in the CR Designer and uncheck the "Default Printer" option.

    Hope this will help!!

    Amit

    Add comment
    10|10000 characters needed characters exceeded