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
Printing textboxes in VB.NET
Hi there.
How do you print the contents of a textbox? I tried using a PrintDocument object, then using
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]
This has been a problem in VB for a long time. The only way I''ve found to do this is to
A) Buy a printing library
B) Code your own
C) Rather use VBA to print.
Goodluck.
A) Buy a printing library
B) Code your own
C) Rather use VBA to print.
Goodluck.
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
"If there is a God, he is a malign thug."
-- Mark Twain
quote:
Original post by Arild Fines
Read the docs.
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]
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
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!
Later!
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement