0
我在做計費應用程序,因此我需要在沒有預覽報告的情況下打印帳單。而且,我不喜歡在打印機對話框中選擇打印機。它應該選擇默認打印機。如何在Windows應用程序中使用C#顯示預覽和打印機選擇而無需顯示預覽和打印機選擇
'PrintToPrinter'不適合我的要求。我需要發送最新創建的BillID作爲參數以獲取最新的細節。
如果我不使用'PrintToPrinter
'語法,打印機對話框彈出屏幕將隨「選擇打印機」對話框提供。
請指導我解決這個問題。
供您參考,我附上一個片段我的代碼:
Report_Path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\Reports\\StandardBill.rpt";
ReportDocument rd = new ReportDocument();
rd.Load(Report_Path);
rd.SetDatabaseLogon(AccessingData.DBUserName, AccessingData.DBPassword);
ParameterFields paramFields = new ParameterFields();
ParameterField BillID = new ParameterField();
ParameterDiscreteValue discreteVal_BillID = new ParameterDiscreteValue();
BillID.ParameterFieldName = "BillNo";
discreteVal_BillID.Value = Convert.ToInt32(Bill_id);
BillID.CurrentValues.Add(discreteVal_BillID);
ParameterField CType = new ParameterField();
ParameterDiscreteValue discreteVal_CType = new ParameterDiscreteValue();
CType.ParameterFieldName = "ClientType";
discreteVal_CType.Value = ClientType;
CType.CurrentValues.Add(discreteVal_CType);
// Add parameter to the parameter fields collection.
paramFields.Add(BillID);
paramFields.Add(CType);
CRViewer1.ParameterFieldInfo = paramFields;
CRViewer1.ReportSource = rd;
CRViewer1.PrintReport();
rd.Close();
rd.Dispose();