For Programmers: Free Programming Magazines  


Home > Archive > C# > June 2004 > PrintToPrinter # copies problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author PrintToPrinter # copies problem
Jen

2004-06-03, 7:31 pm

I have a strange error. I am creating a crystal report and then using
the PrintToPrinter function to send it to the printer. The user wants
the number of copies to default to 3, which I have done, but now when
they change the number of copies to 1 it will always print 2 copies. I
can set the copies to any number above 1 and it will print the number
I request, but it will not print one copy. Any help would be greatly
appreciated. I have messed with this for too many hours already.

Here is my print to printer code:

short iCopies = 3;
frmMain fmain = (frmMain)this.MdiParent;
fmain.Cursor = Cursors.WaitCursor;
rptMxShop mxs = new rptMxShop();
frmCrystal fc = new frmCrystal();

fc.CrystalViewerReportConnection.ConnectionString = fmain.ConnString;
fc.CrystalViewerDAMxShop.SelectCommand.Connection =
fc.CrystalViewerReportConnection;
fc.CrystalViewerDAMxShop2.SelectCommand.Connection =
fc.CrystalViewerReportConnection;

fc.CrystalViewerDAMxShop.SelectCommand.Parameters["@OrderNum"].Value =
txtOrderNo.Text;
fc.CrystalViewerDAMxShop.SelectCommand.Parameters["@Date"].Value =
txtDate.Text;
fc.CrystalViewerDAMxShop2.SelectCommand.Parameters["@OrderNum"].Value
= txtOrderNo.Text;
fc.CrystalViewerDAMxShop2.SelectCommand.Parameters["@Date"].Value =
txtDate.Text;

fc.CrystalViewerDAMxShop.Fill(fc.CrystalViewerDataSet1);
fc.CrystalViewerDAMxShop2.Fill(fc.CrystalViewerDataSet1);

mxs.SetDataSource(fc.CrystalViewerDataSet1);
fc.CrystalViewerReportSource.ReportSource= mxs;

pDlgShop.Document.PrinterSettings.Copies = iCopies;

if(DialogResult.OK == pDlgShop.ShowDialog())
{
mxs.PrintOptions.PrinterName =
pDlgShop.Document.PrinterSettings.PrinterName.ToString();
iCopies = pDlgShop.Document.PrinterSettings.Copies;
mxs.PrintToPrinter(iCopies, false, 0, 0);
}

fmain.Cursor = Cursors.Default;
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com