Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » vb.net print to printer text from RichTextBox

Credits go to BAF and jmasterx for helping out!
This thread is locked; no one can reply to it. rss feed Print
vb.net print to printer text from RichTextBox
van_houtte
Member #11,605
January 2010
avatar

Hello,

I looked around, but I can't seem to find a simple and clear answer.

I have a bunch of text that has been formated and is being displayed correctly in a RichTextBox

What code will print to a printer what is in the RichTextBox?

Thanks

-----
For assistance, please register and click on this link to PM a moderator

Sometimes you may have to send 3-4 messages

jmasterx
Member #11,410
October 2009

To lead you in the right direction, if I recall correctly, the way printing works in Windows is with GDI. So basically you get a graphics context for a printer, you then do things like g.drawImage(...), etc, and paint into your context, the context is then printed by the printer. It's not the funnest thing in the world to print like this. As for printing rtf, I've never done so, you might have to manually figure out the font metrics of each word and do g.drawString or something.

Good Luck :)

This seems like a good start http://www.dreamincode.net/forums/topic/44150-printing-in-vbnet/

BAF
Member #2,981
December 2002
avatar

Your google-fu is weak.

On first page of Google results. Convert to VB and you're done.

van_houtte
Member #11,605
January 2010
avatar

converting from c# to vb, isnt simple to me, but I found this http://support.microsoft.com/kb/811401 it was one of the first results and it works great, i found this first but i thought there might've been a simple code such as

PrintThis(RichTextbox)

-----
For assistance, please register and click on this link to PM a moderator

Sometimes you may have to send 3-4 messages

BAF
Member #2,981
December 2002
avatar

What's so hard about it? Your sig says you're an expert programmer, so surely you know C or C++ or C# or something similar enough to understand the gist of what's going on. .NET is .NET, so you shouldn't have any API problems - you should be able to get away with literally translating it from C# to VB.

van_houtte
Member #11,605
January 2010
avatar

thanks for the input BAF, your article has helped me add more code to the KLAXXXZ GAME MAKER vb.net api

-----
For assistance, please register and click on this link to PM a moderator

Sometimes you may have to send 3-4 messages

jmasterx
Member #11,410
October 2009

Go to: