Public Group

#### Archived

This topic is now archived and is closed to further replies.

# Printing textboxes in VB.NET

This topic is 5640 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi there. How do you print the contents of a textbox? I tried using a PrintDocument object, then using

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
e.Graphics.DrawString(txtWindow.Text, 0, 0)
End Sub

Where: txtWindow.Text is my textbox text. All this seems to do is print only one line of text, which isn't useful. It seems that though the textbox is multiline, it is still treated as a single-line string. Is there any way around this? [edited by - light-nexus on March 30, 2003 3:32:34 PM]

##### Share on other sites
I guess no one knows...heh.

##### Share on other sites
This has been a problem in VB for a long time. The only way I''ve found to do this is to
C) Rather use VBA to print.

Goodluck.

##### Share on other sites
Try one of the DrawString overloads that take a layoutRectangle and a StringFormat argument. Read the docs.

"If there is a God, he is a malign thug."
-- Mark Twain

##### Share on other sites
quote:

Original post by Arild Fines

In the case of Microsoft finding the information you want can often be daunting. I find RTFM replies on questions to usually be off the mark.

I spent a good deal of time on Friday simply looking for a note on Excel automation on msdn.microsoft.com. It was, quite literally, a needle in the haystack.

[edited by - Talonius on March 31, 2003 9:35:10 AM]

##### Share on other sites
quote:
Original post by Talonius
In the case of Microsoft finding the information you want can often be daunting. I find RTFM replies on questions to usually be off the mark.

Perhaps, but in this case he knows exactly where to look: The DrawString methods on the Graphics class.

quote:

I spent a good deal of time on Friday simply looking for a note on Excel automation on msdn.microsoft.com. It was, quite literally, a needle in the haystack.

The automation model is documented in the Excel help file. On my machine and Office2K thats I:\Program Files\Microsoft Office\Office\1033\XLMAIN9.chm. Look for a topic called "Programming information".

"If there is a God, he is a malign thug."
-- Mark Twain

##### Share on other sites
Thanks for your help everyone. I guess DrawString is what I will use for now. About msdn.microsoft.com: It is indeed a haystack for any needle of information you need. If you search for something very simple, you get gobs of stuff you don''t need. I hardly ever use MSDN at all.

Later!

##### Share on other sites
quote:
Original post by light-nexus
About msdn.microsoft.com: It is indeed a haystack for any needle of information you need. If you search for something very simple, you get gobs of stuff you don''t need. I hardly ever use MSDN at all.

I suggest you keep trying to figure out how to use MSDN - it is well worth when you know how to find the stuff you need on there.

I can give you one little tip: Don''t use MS'' own search engine. Google is usually better, even for MSDN. Just put site:msdn.microsoft.com after your search criteria. That will limit the google search to the msdn pages.

That being said, it is usually faster and easier to find something in your local copy of the docs, especially since they have a proper index.

"Laughter means distance. Where laughter is absent, madness begins. The moment one takes the world with complete seriousness one is potentially insane. The whole art of learning to live means holding fast to laughter; without laughter the world is a torture chamber, a dark place where dark things will happen to us, a horror show filled with bloody deeds of violence."
-- Jens Bjørneboe

1. 1
2. 2
3. 3
Rutin
22
4. 4
frob
18
5. 5

• 33
• 13
• 11
• 10
• 12
• ### Forum Statistics

• Total Topics
632572
• Total Posts
3007128

×