Print a crystal report with print options

Jelmer

Well-known member
Joined
Jan 11, 2006
Messages
96
Hello

I try to print my crystal report with some print options.
This is what i get:

Code:
            CrystalReport1 print = new CrystalReport1();         
            printDialog1.PrinterSettings.Copies = 2;
            printDialog1.ShowDialog();

The dialog is displayed...

And i like to print the report:

Code:
print.PrintToPrinter(1, Convert.ToBoolean(1), 0, 1);

But that doesnt work... , it just print the document to the normal printer, also if i tell him to print it to another...
Normally without the printdialog it works perfect!
But i like to set the print conditions...
 
Extracted from our system, so may not work completely as-is

Code:
			Dim pd As New PrintDialog
			pd.Document = New Printing.PrintDocument
			pd.AllowSelection = False
			If pd.ShowDialog = DialogResult.OK Then
				Me.Cursor = Cursors.WaitCursor

				Dim rpt As New rptProductionSchedule
				Reporting.SetDatabaseForReport(rpt)
				rpt.SetParameterValue(0, Prodate)
				rpt.SetParameterValue(1, Hours)
				rpt.PrintOptions.PrinterName = pd.PrinterSettings.PrinterName
				rpt.PrintToPrinter(pd.PrinterSettings.Copies, pd.PrinterSettings.Collate, pd.PrinterSettings.FromPage, pd.PrinterSettings.ToPage)
				rpt.Close()
				rpt.Dispose()
			End If
                        pd.Close()
			pd.Dispose()
 
This works okay::

Code:
            CrystalReport1 print = new CrystalReport1();
            printDialog1.PrinterSettings.Copies = 2;
            printDialog1.ShowDialog();
            //print.PrintOptions = printDialog1.PrinterSettings.
            print.PrintOptions.PrinterName = printDialog1.PrinterSettings.PrinterName;
            print.PrintToPrinter(printDialog1.PrinterSettings.Copies, printDialog1.PrinterSettings.Collate, printDialog1.PrinterSettings.FromPage, printDialog1.PrinterSettings.ToPage);
           // print.PrintToPrinter(1, Convert.ToBoolean(1), 0, 1);
            NieuwFactuur_Load(sender, e);
 
Back
Top