Crystal Reports PrintToPrinter Method

  • Thread starter Thread starter Alx Sharp
  • Start date Start date
A

Alx Sharp

Hello group!

I'm facing a strange problem in the application I'm writing...

I'm using crystal reports for printing sale receipts, and I wrote this lines of code:

rpt.Parameter_SaleID.CurrentValues.AddValue((int)this.CurrentSale.Row["SaleID"]);
rpt.Parameter_TaxValue.CurrentValues.AddValue(tax);
rpt.PrintOptions.PrinterName = "SAMSUNG SRP270";
rpt.SetDataSource(this.salesDataSet);
rpt.PrintToPrinter(1, false, 0, 0);

In my report I'm using parameter fields to set the record selection formula and to apply taxes.
Every line works fine, except for the last one, which rises the exception IndexOutOfRangeException that idicates that the index doesn't fit in the matrix (I don't know why).

If I use the report viewer to show a preview of the sale receipt, I can print it from the tool bar, but I don't want to use the viewer.

I'd really appreciate your help...

Thank you all...
 
Can you post the exact text of the error message that you're getting?
As in, make it happen, then copy and paste it here?
 
Hello group!!!

I'm going to reply to myself... :)

I can call the PrintToPrinter method if I set the PrintOptions.PageMargins
data before:

CrystalDecisions.Shared.PageMargins pageMargins = new
CrystalDecisions.Shared.PageMargins(1, 1, 1, 1);

rpt.PrintOptions.ApplyPageMargins(pageMargins);
rpt.PrintOptions.PrinterName = "SAMSUNG SRP270";
rpt.PrintToPrinter(1, false, 0, 0);

Now my application is working fine...

Anyway... thank you all...
 
Back
Top