cancel
Showing results for 
Search instead for 
Did you mean: 

Setting a Printer Tray in C#

john_noble3
Participant
0 Kudos

Hi Folks,

I am having difficulty in getting the printouts to come from the desired tray in my WinFOrmas App using an OKI B721 Laser printer.

The form has radio buttons for selecting the desired tray. But regardless of the tray I select, the print out ALWAYS comes comes out of the same tray.

Here is my code:

// Get Report
ReportDocument rep = new ReportDocument();
rep.Load("cheque.rpt");
// Create Printer Settings object
System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();
printerSettings.PrinterName = "OKILaser";

// Set Printer Tray
if (rdoAuto.Checked)
rep.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Auto;
else if (rdoCassette.Checked)
rep.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Cassette;
else if (rdoEnvelope.Checked)
rep.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Envelope;
else if (rdoEnvelopeManual.Checked)
rep.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.EnvManual;
else if (rdoFormSource.Checked)
rep.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.FormSource;
else if (rdoLargeCapacity.Checked)
rep.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.LargeCapacity;
else if (rdoLargeFMT.Checked)
rep.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.LargeFmt;
else if (rdoLower.Checked)
rep.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Lower;
else if (rdoManual.Checked)
rep.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Manual;
else if (rdoMiddle.Checked)
rep.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Middle;
else if (rdoSmallFMT.Checked)
rep.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.SmallFmt;
else if (rdoTractor.Checked)
rep.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Tractor;
else if (rdoUpper.Checked)
rep.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Upper;
// Send to Printer rep.PrintToPrinter(printerSettings, new System.Drawing.Printing.PageSettings(), false);

Accepted Solutions (1)

Accepted Solutions (1)

john_noble3
Participant
0 Kudos

Hello again,

I think I have found the solution.

I needed to define the PageSettings Object rather than creating a new instance like so...

System.Drawing.Printing.PageSettings ps = new System.Drawing.Printing.PageSettings();
ps.PaperSource = new System.Drawing.Printing.PaperSource() { RawKind = (int)CrystalDecisions.Shared.PaperSource.Upper };
// Send to Printer
rep.PrintToPrinter(printerSettings, ps, false);

Answers (0)