c# - Crystal report not printing as it shows while design time when using PrintToPrinter method -
hi intelligent peoples,
i stuck @ problem , cant find solution anywhere on internet.
problem : printtoprinter method not print same design. print out same when printing preview of crystal report in crystal report viewers, user don't want click print on windows form , press print again in print preview(crystal report viewer). want print report directly printer without asking user again.
page setup:
page size : 8.5*8.5 inches.
no printer(optimize screen size) : checked
dissociate formatting page size , printer paper size : checked
user defined size : selected
printout crystalreportviewer desired. printed paper printtoprinter method comes different.
please me, stuck.
edit: following event handler btnprint
. want user click on btnprint
on windows form once , want print out. no other step. print comes out not expected.
if open crystal report viewer on click of btnprint
after user clicks on print button on crystal report viewer , after selecting printer clicks print button on print dialog, printer prints expected. eliminating steps doesn't prints ago.
hope understood @amazing
private void btnprint_click(object sender, eventargs e) { if (txtbillno.enabled == false) { if (cmbpartyname.enabled == false) { string strselectpartyid = "select partyid partylist partyname ='" + cmbpartyname.text + "' , 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 * billlist billno = " + txtbillno.text + " , companyid = " + companyid.tostring(); string strselectparty = "select * partylist partyid = " + partyid.tostring(); string strselectitem = "select * itemlist companyid = " + companyid.tostring() + " , 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 bill first."); } }
Comments
Post a Comment