嗨聪明人,
我遇到了问题,我无法在互联网上找到解决方案。
问题:PrintToPrinter方法的打印方式与Design不同。但是在水晶报表查看器中从水晶报表的预览打印时打印输出相同,但是用户不想在Windows窗体上单击打印并在打印预览(Crystal Report Viewer)中再次按打印。所以基本上我想直接将报告打印到打印机而不再询问用户。
页面设置:
页面尺寸为:8.5 * 8.5英寸 没有打印机(针对屏幕尺寸进行了优化):检查了 分离格式页面尺寸和打印机纸张尺寸:已检查
用户定义的大小:已选择
CrystalReportViewer的打印输出是所需的。 但PrintToPrinter方法的打印纸不同。
请帮帮我, 我被卡住了。
修改
以下是btnPrint
的事件处理程序。
我希望用户在Windows窗体上单击btnPrint
一次,然后打印出来。没有任何其他步骤。
打印出来但不是预期的。
如果在用户单击Crystal报表查看器上的打印按钮后单击btnPrint
打开Crystal Report Viewer,并且在选择打印机单击打印对话框上的打印按钮后,打印机将按预期打印。
但是,取消这些步骤并不像以前那样打印。
希望你能理解@aMazing
private void btnPrint_Click(object sender, EventArgs e)
{
if (txtBillNo.Enabled == false)
{
if (cmbPartyName.Enabled == false)
{
string strSelectPartyID = "SELECT PartyID from PartyList WHERE PartyName ='" + cmbPartyName.Text + "' AND CompanyID = " + companyID.ToString();
con = u.connect();
OleDbCommand cmdPartyID = new OleDbCommand(strSelectPartyID, con);
con.Open();
OleDbDataReader drPartyID = cmdPartyID.ExecuteReader();
drPartyID.Read();
partyID = drPartyID[0].ToString();
}
string strSelectBill = "SELECT * FROM BillList WHERE BillNo = " + txtBillNo.Text + " AND CompanyID = " + companyID.ToString();
string strSelectParty = "SELECT * FROM PartyList WHERE PartyID = " + partyID.ToString();
string strSelectItem = "SELECT * FROM ItemList WHERE CompanyID = " + companyID.ToString() + " AND BillNo = " + txtBillNo.Text;
OleDbDataAdapter daBillList = new OleDbDataAdapter(strSelectBill, con);
OleDbDataAdapter daItemList = new OleDbDataAdapter(strSelectItem, con);
OleDbDataAdapter daPartyList = new OleDbDataAdapter(strSelectParty, con);
DataSet dsBRSystem = new DataSet("BRSystem");
DataTable dtBillList = new DataTable("BillList");
DataTable dtPartyList = new DataTable("PartyList");
DataTable dtItemList = new DataTable("ItemList");
crpCodePrint crpBillPrint = new crpCodePrint();
frmDemoPrint DemoPrint = new frmDemoPrint();
daBillList.Fill(dtBillList);
daPartyList.Fill(dtPartyList);
daItemList.Fill(dtItemList);
dsBRSystem.Tables.Add(dtBillList);
dsBRSystem.Tables.Add(dtItemList);
dsBRSystem.Tables.Add(dtPartyList);
crpBillPrint.SetDataSource(dsBRSystem);
DemoPrint.crvDemo.ReportSource = crpBillPrint;
DemoPrint.crvDemo.RefreshReport();
//DemoPrint.Show();
//crpBillPrint.PrintToPrinter(1, false, 0, 0);
//DemoPrint.crvDemo.PrintReport();
PrinterSettings printSetting = new PrinterSettings();
printSetting.PrinterName = "Samsung SCX-3400 Series";
PaperSize paperSetting = new PaperSize("Custom", 850, 850);
PageSettings pageSetting = new PageSettings(printSetting);
pageSetting.PaperSize = paperSetting;
pageSetting.Landscape = false;
crpBillPrint.PrintToPrinter(printSetting, pageSetting, true);
}
else
{
MessageBox.Show("Please SAVE the Bill first.");
}
}