Printing the contents of a textbox

G

Guest

In VB i had some very very simple code that would print out the contents of a
textbox for me.

It was simply

Sub PrintTB()
Printer.Print(Text1.Text)
End sub

Very simple, and 110% effective.

How the hell do i do this in VB .Net???
 
H

Herfried K. Wagner [MVP]

Jonathan Smith said:
In VB i had some very very simple code that would print out the contents
of a
textbox for me.

It was simply

Sub PrintTB()
Printer.Print(Text1.Text)
End sub

Very simple, and 110% effective.

How the hell do i do this in VB .Net???

That's not as easy. You will have to use the 'PrintDocument' object and
draw the string onto the printer using 'e.Graphics.ToString' in the
'PrintDocument''s 'PrintPage' event handler. 'PrintDocument' won't to
paging automatically, so you'll have to measure the text you are printing
and start a new page using 'e.HasMorePages' manually, which will cause
'PrintPage' to be called one more time for the next page.
 
G

Guest

Jonathan,

The .Net framework includes classes that allow you to build sophisticated
print capabilities into an app.

But something as simple as the VB6 Printer object is not included.

You can google for .Net printing and find several third-party tools that
attempt to give you capabilities similar to the VB6 Printer object. I have
not tried these tools so I can't recommend any of them.

Kerry Moorman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top