Printing contents of textbox wth VB.Net?

G

Grahammer

This is a stupid question, but the examples I've seen don't make sense to
me...

I simply want to print the contents of a textbox to a printer when the user
clicks a button on my form. Printing to the default printer is fine, but
eventually I will want the user to be able to choose a printer (not
necessarily at print time).

Can someone show or link me to a simple sample of the CLICK event for a
print button that just dumps the contents of TEXTBOX1 to the default
printer?

Thanks
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi,

There is good article in MSDN Magazine illustrating how to output a text
file to a printer. This was definitely this year issue, but I don't remember
the exact month. It is little bit more complex, but you should get the basic
idea and simplify the example to fit your needs by replacing the file
content with TEXTBOX1 content and wiring the Click event handler the way you
need it.
 
H

Herfried K. Wagner [MVP]

* "Grahammer said:
This is a stupid question, but the examples I've seen don't make sense to
me...

I simply want to print the contents of a textbox to a printer when the user
clicks a button on my form. Printing to the default printer is fine, but
eventually I will want the user to be able to choose a printer (not
necessarily at print time).

Can someone show or link me to a simple sample of the CLICK event for a
print button that just dumps the contents of TEXTBOX1 to the default
printer?

You will find a sample for printing + printer selection here (notice
that comments are only avalilable in German):

<http://www.mvps.org/dotnet/dotnet/samples/printing/downloads/PrintFramework.zip>
 
P

Phrederick

Thanks

I've seen a few examples of this... But for some reason it just doesn't
*click* for me. My head is still in GWBasic, although I've done a fair bit
of work with VB6. I think the file handling is confusing me as well.

It could just be trying to read it on the screen instead of on paper that's
causing me some trouble. For some reason hardcopy is easier for me to
follow.

Thanks again!

Dmitriy Lapshin said:
Hi,

There is good article in MSDN Magazine illustrating how to output a text
file to a printer. This was definitely this year issue, but I don't remember
the exact month. It is little bit more complex, but you should get the basic
idea and simplify the example to fit your needs by replacing the file
content with TEXTBOX1 content and wiring the Click event handler the way you
need it.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Grahammer said:
This is a stupid question, but the examples I've seen don't make sense to
me...

I simply want to print the contents of a textbox to a printer when the user
clicks a button on my form. Printing to the default printer is fine, but
eventually I will want the user to be able to choose a printer (not
necessarily at print time).

Can someone show or link me to a simple sample of the CLICK event for a
print button that just dumps the contents of TEXTBOX1 to the default
printer?

Thanks
 
P

Phrederick

Herfried K. Wagner said:
You will find a sample for printing + printer selection here (notice
that comments are only avalilable in German):
<http://www.mvps.org/dotnet/dotnet/samples/printing/downloads/PrintFramework
..zip>

Thanks... Looks interesting.

I should be able to figure out most of the comments and use Babelfish to
convert any others.

This is starting to look like there is no simple way to just print a couple
lines of text. BLECH!
 

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