.net - How to send a textbox to a printer -
i writing program in visual basic, want users print contect of textbox1.text
this code part:
private sub button4_click(sender object, e eventargs) handles button4.click printdialog1.document = printdocument1 printdialog1.printersettings = printdocument1.printersettings printdialog1.allowsomepages = true if printdialog1.showdialog = dialogresult.ok printdocument1.printersettings = printdialog1.printersettings printdocument1.print() end if end sub
could me?
you not printing anything. have @ page. has worked example of how printing.
basically need put code printdocument.printpage
event.
for exmaple:
private sub printdocument_printpage(byval sender object, byval ev printpageeventargs) handles printdocument1.printpage dim linesperpage single = 0 dim ypos single = 0 dim count integer = 0 dim leftmargin single = ev.marginbounds.left dim topmargin single = ev.marginbounds.top dim line string = nothing ' calculate number of lines per page. linesperpage = ev.marginbounds.height / printfont.getheight(ev.graphics) ' print each line of file. while count < linesperpage line = streamtoprint.readline() if line nothing exit while end if ypos = topmargin + count * printfont.getheight(ev.graphics) ev.graphics.drawstring(line, printfont, brushes.black, leftmargin, ypos, new stringformat()) count += 1 end while ' if more lines exist, print page. if (line isnot nothing) ev.hasmorepages = true else ev.hasmorepages = false end if end sub
Comments
Post a Comment