winforms - Printing vb.net forms with a loop -
hi tring print multiple copies of box labels on form using vb.net
the copies depent on amount of boxes on job , range 1 500 copies. print these print choosen box number if required. can 1 attempts have failed.
the problem captures screen including msgboxs of currenting being printed or done , calls them document 1. there simple way print without screen capture.
here code @ moment
imports system imports system.windows.forms imports system.drawing imports system.drawing.printing public class print inherits form private withevents printbutton new button private withevents printdocument1 new printdocument dim memoryimage bitmap private sub capturescreen() dim mygraphics graphics = me.creategraphics() dim s size = me.size memoryimage = new bitmap(s.width, s.height, mygraphics) dim memorygraphics graphics = graphics.fromimage(memoryimage) memorygraphics.copyfromscreen(me.location.x, me.location.y, 0, 0, s) end sub private sub printdocument1_printpage(byval sender system.object, _ byval e system.drawing.printing.printpageeventargs) handles _ printdocument1.printpage e.graphics.drawimage(memoryimage, 0, 0) end sub private sub printbutton_click(byval sender system.object, byval e system.eventargs) handles printbutton.click dim numberofboxes integer = 3 dim startbox integer = 1 dim counter integer = 1 index integer = startbox numberofboxes capturescreen() printdocument1.print() lblfirstboxprint.text = counter counter = counter + 1 printdocument1.printersettings.printtofile = true printdocument1.printersettings.printfilename = "c:\users\joseph\desktop\test '" & counter & "'.xps" printdocument1.print() next end sub public shared sub main() application.run(new print()) end sub private sub print_load(sender object, e eventargs) handles mybase.load printbutton.text = "print form" me.controls.add(printbutton) end sub end class
if desire print form, appears on screen, consider built-in printform component. after adding component, , setting properties, printing 1 line process.
printform1.print()
see msdn tutorial further details.
Comments
Post a Comment