473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Question: PrintDocument_PrintPage - only does what's visible

I have a multiline text box with a scroll bar. I want to print out the
ENTIRE contents of the text box, but it's only printing what's visible.

Here's my PrintPage code:

Private Sub PrintDocument_PrintPage(ByVal sender As System.Object, ByVal
e As System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument.PrintPage
Try
e.Graphics.DrawString(txtDisplay.Text, New
Font(txtDisplay.Font.Name, txtDisplay.Font.Size,
FontStyle.Regular),Brushes.Black, 150, 125)
Catch ex As Exception
HandleError(ex, "PrintDocument_PrintPage")
End Try
End Sub

Any ideas how to do this?
Nov 20 '05 #1
2 1885
Hi,

The version of drawstring you are using will print on only one line.
If you use a drawstring that takes a rectanglef it will word wrap for you.

g.DrawString(textbox1.text, textbox1.font, Brushes.Black,
RectangleF.op_Implicit(e.PageBounds))
Ken
----------------------------
"VB Programmer" <gr********@go-intechN0SPAM.com> wrote in message
news:up*************@TK2MSFTNGP11.phx.gbl...
I have a multiline text box with a scroll bar. I want to print out the
ENTIRE contents of the text box, but it's only printing what's visible.

Here's my PrintPage code:

Private Sub PrintDocument_PrintPage(ByVal sender As System.Object,
ByVal
e As System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument.PrintPage
Try
e.Graphics.DrawString(txtDisplay.Text, New
Font(txtDisplay.Font.Name, txtDisplay.Font.Size,
FontStyle.Regular),Brushes.Black, 150, 125)
Catch ex As Exception
HandleError(ex, "PrintDocument_PrintPage")
End Try
End Sub

Any ideas how to do this?

Nov 20 '05 #2
Thanks. That works better, but, it still only prints page 1. I assume I
have to use the HasMorePages property. Can someone post a link or simple
example? There can be 2-4 pages.

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

The version of drawstring you are using will print on only one line. If you use a drawstring that takes a rectanglef it will word wrap for you.

g.DrawString(textbox1.text, textbox1.font, Brushes.Black,
RectangleF.op_Implicit(e.PageBounds))
Ken
----------------------------
"VB Programmer" <gr********@go-intechN0SPAM.com> wrote in message
news:up*************@TK2MSFTNGP11.phx.gbl...
I have a multiline text box with a scroll bar. I want to print out the
ENTIRE contents of the text box, but it's only printing what's visible.

Here's my PrintPage code:

Private Sub PrintDocument_PrintPage(ByVal sender As System.Object,
ByVal
e As System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument.PrintPage
Try
e.Graphics.DrawString(txtDisplay.Text, New
Font(txtDisplay.Font.Name, txtDisplay.Font.Size,
FontStyle.Regular),Brushes.Black, 150, 125)
Catch ex As Exception
HandleError(ex, "PrintDocument_PrintPage")
End Try
End Sub

Any ideas how to do this?


Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: AnalogKid | last post by:
Short question: What's the difference between SingleUse and MultiUse ? Long question: I've been writing some sample code to see how different Instancing values and threading models work. I...
11
by: Markus Breuer | last post by:
I have a question about oracle commit and transactions. Following scenario: Process A performs a single sql-INSERT into a table and commits the transaction. Then he informs process B (ipc) to...
5
by: Erwin | last post by:
At the moment I'm using a report which contains an indicator to show if a Service group of the company isn't working well or is working perfectly. This indicator is a "*" which looks like a traffic...
5
by: John | last post by:
Hi, I have an asp.net form where if the user enters an incorect date I change the color of the textbox to red and also display a label field with a message saying the date is invalid. What I...
0
by: VB Programmer | last post by:
I have a multiline text box with a scroll bar. I want to print out the ENTIRE contents of the text box, but it's only printing what's visible. Here's my PrintPage code: Private Sub...
4
by: Ferret Face | last post by:
Hello, Folks! I have a large number of web object appearing on the same page so I decided to break them down into a number of panels with some control buttons like "Prev" and "Next" to make the...
2
by: Jeff | last post by:
....another beginner question - using visual web 2005 with VB I have 20 labels - lbl1 through lbl20 I have a listbox containing values 1 through 20 I need to make label 1 through the...
6
by: moti | last post by:
Whenever I use PrintDocument.Print() to print a page it goes to PrintDocument_PrintPage and stays there forever unless I set e.HasMorePages to False. When I set it to False it prints the page but...
0
by: | last post by:
I have a question about spawning and displaying subordinate list controls within a list control. I'm also interested in feedback about the design of my search application. Lots of code is at the...
2
by: DK | last post by:
I have an asp.net web site which has GridViews on many pages. They are different except they all have a common Pager Template. On the DataBound event, I customize this template based on the number...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.