Click here to Skip to main content
13,514,019 members
Click here to Skip to main content
Add your own
alternative version


44 bookmarked
Posted 7 Dec 2005

Choosing a printer when printing from Crystal Reports in C#

, 7 Dec 2005
Rate this:
Please Sign up or sign in to vote.
How to choose a printer when printing from Crystal Reports in C#.


I use Crystal Reports 9 in my project. I once encountered an issue with printing a report. Then, I searched the Internet and found a code from this website that showed me how to send a report to the printer without previewing it, but the code did not allow me to choose the printer. In this article, I have customized the code to use a Print Dialog to choose the printer.

Using the code

I use the Print Dialog to get the printer name. Then, I assign it to the report. To print the report, I use the method:

crReportDocument.PrintToPrinter(nCopy, false, sPage, ePage);

to send the data from the report to the printer.

The code below shows how to choose the printer to print the report:

private void button2_Click(object sender, System.EventArgs e)
    //Open the PrintDialog
    this.printDialog1.Document = this.printDocument1;
    DialogResult dr = this.printDialog1.ShowDialog();
    if(dr == DialogResult.OK)
        //Get the Copy times
        int nCopy = this.printDocument1.PrinterSettings.Copies;
        //Get the number of Start Page
        int sPage = this.printDocument1.PrinterSettings.FromPage;
        //Get the number of End Page
        int ePage = this.printDocument1.PrinterSettings.ToPage;
        //Get the printer name
        string PrinterName = this.printDocument1.PrinterSettings.PrinterName;

        crReportDocument = new ReportDocument();
        //Create an instance of a report
        crReportDocument = new Chart();
            //Set the printer name to print the report to. By default the sample
            //report does not have a defult printer specified. This will tell the
            //engine to use the specified printer to print the report. Print out 
            //a test page (from Printer properties) to get the correct value.

            crReportDocument.PrintOptions.PrinterName = PrinterName;

            //Start the printing process. Provide details of the print job
            //using the arguments.
            crReportDocument.PrintToPrinter(nCopy, false, sPage, ePage);

            //Let the user know that the print job is completed
            MessageBox.Show("Report finished printing!");
        catch(Exception err)

Points of Interest

I think the important thing in this article is it shows how to get the names of printers in your computer or your local network.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Le Minh Dat
Vietnam Vietnam
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
bhalaniabhishek26-May-15 2:54
memberbhalaniabhishek26-May-15 2:54 
Questioncrustal reports Pin
panduRajju7-Apr-12 2:13
memberpanduRajju7-Apr-12 2:13 
Questioncrystal reports Pin
panduRajju7-Apr-12 2:12
memberpanduRajju7-Apr-12 2:12 
QuestionHi! Pin
trunduong6-Apr-12 16:35
membertrunduong6-Apr-12 16:35 
GeneralGreat topic... and a suggestion Pin
JRINC9-Feb-11 3:07
memberJRINC9-Feb-11 3:07 
GeneralMy vote of 5 Pin
Kunal Chachad9-Aug-10 11:04
memberKunal Chachad9-Aug-10 11:04 
GeneralThis topic very stupid Pin
taithien4-Jun-08 1:11
membertaithien4-Jun-08 1:11 
GeneralRe: This topic very stupid Pin
J Keith Montz28-Apr-10 5:26
memberJ Keith Montz28-Apr-10 5:26 
GeneralRe: This topic very stupid Pin
DarkBintje7-Jun-10 6:53
memberDarkBintje7-Jun-10 6:53 
GeneralRe: This topic very stupid Pin
JRINC9-Feb-11 2:23
memberJRINC9-Feb-11 2:23 
GeneralWindows form design Pin
suki217930-Aug-07 20:38
membersuki217930-Aug-07 20:38 
GeneralRe: Windows form design Pin
JRINC9-Feb-11 3:01
memberJRINC9-Feb-11 3:01 
GeneralResize width and height of Crystal Report Pin
thanhtc24915-Apr-07 17:10
memberthanhtc24915-Apr-07 17:10 
GeneralNetwork Printer Pin
farhan1406-Apr-07 23:24
memberfarhan1406-Apr-07 23:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180417.1 | Last Updated 7 Dec 2005
Article Copyright 2005 by Le Minh Dat
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid