c# 4.0 - Unable to print a panel in c# windows application -
hi printing panel in windows application. when click print panel opening print dialog after click print in print dailog is throwing exception.
system.compoentmodel.win32exception{"access denied"}
here code using.
bitmap memoryimage; private void btnprint_click(object sender, eventargs e) { panel1.backcolor = color.white; printdialog1.document = printdocument1; if (printdialog1.showdialog() == dialogresult.ok) { printdocument1.print(); } } private void printdocument1_printpage(object sender, printpageeventargs e) { rectangle pagearea = e.pagebounds; e.graphics.drawimage(memoryimage, (panel1.width / 2) - (this.panel1.width / 2), this.panel1.location.y); }
please let me know how solve this
thanks in advance
try it
private void printdocument1_printpage(object sender, system.drawing.printing.printpageeventargs e) { system.drawing.bitmap memoryimage = new system.drawing.bitmap(panel1.width, panel1.height); rectangle pagearea = e.pagebounds; panel1.drawtobitmap(memoryimage, panel1.clientrectangle); e.graphics.drawimage(memoryimage, (pagearea.width / 2) - (this.panel1.width / 2), this.panel1.location.y); }
Comments
Post a Comment