I am doing a crystal report with printing. I have encountered on this problem:

try
                {
                    PrintDialog print = new PrintDialog();
                    print.ShowDialog();
                    crystalReportViewer1.ReportSource = cr1;
                    crystalReportViewer1.PrintReport();
                    cr1.Refresh();
                    cr1.PrintToPrinter(1, true, 1, 1);
                }
                catch
                {
                    //MessageBox.Show("Some error occured...", "Opozorilo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

I got an error on last line of the code (print to printer).

What am I misisng here?

Recommended Answers

All 4 Replies

Care to share the actual error? It may provide a clue as to what caused it :)

PrintDialog print = new PrintDialog();

print.ShowDialog();

crystalReportViewer1.ReportSource = cr1;

cr1.PrintToPrinter(1, true, 1, 1);

try this must work for u
if work dont forgate to mark as solved ok

The error is simple: "Missing parameter values".
Dont`t worry about marking as salved. It`s not my 1st time here.

btw, can someone give me a shot explanation. What`s the difference between PrintDialog and cr1.PrintToPrinter?
Becuase with both of them I can seperately do printing. I mean its not necessary to use them both.
And finaly what do u suggest to use in general?

Now I use only this part of the code:

crystalReportViewer1.ReportSource = cr1;
crystalReportViewer1.PrintReport();
cr1.Refresh();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.