Printing multiple pages

AllanB

New member
Joined
Nov 27, 2003
Messages
1
I am attempting to print out payment coupons based on the length of a loan, ie 12months = 12 coupons.

Y = the y coordinate of the text string. Y is incremented by 100 each loop to cause the next coupon to print just below the previous. If the value of y reaches 1000, then the I need to start another page.

My Problem is it will only print one page (10 coupons). This is my first attempt at printing in DotNet and Im just a little confused as to the proper syntax.

If I leave out the "Else e.hasmorepages = false" it spools endlessly.


Print Coupon
For N = 1 To g_intLength
g.DrawString(strCoupons, Font, Brushes.Black, 10, y)
y = y + 100
If y >= 1000 Then
y = 10
e.HasMorePages = True
Else
e.HasMorePages = False
End If
Next N
 
try this instead:
[VB]
...
Print Coupon
For N = 1 To g_intLength

If N2 <> 0 then
N = N2
End If

g.DrawString(strCoupons, Font, Brushes.Black, 10, y)
y += 100
If y >= 1000 Then
N2 = N
Exit For
End If
Next N

If y >= 1000 Then
y = 10
e.HasMorePages = True
Else
e.HasMorePages = False
End If
End Sub

Protected N2 as Integer
[/VB]

Just for Explanation: oPrintDoc_PrintPage is called every time you print a page until you stop it using e.Hasmorepages = false.

I dont know if I got your intention correctly, but I think with some minor modifications this will do the trick. Let me know if you need any further help

Voca
 
When printing from a text file the above works fine, but how do you print from a database. Ive spent a long time trying to loop through the records in a database table and print them, the problem is if you have more records than lines per page how do you make the rest of the records print on another page. I have tried to set the HasMorePages = true, but this does not seem to work.

Code Snipet Below
--------------------------

While oDr.Read
Dim col1, col2, col3, col4 As String

col1 = oDr.Item("Reg")
col2 = oDr.Item("Make")
col3 = oDr.Item("Model")
col4 = oDr.Item("ServiceDue")

yPos = TopMargin + count * myfont.GetHeight(ev.Graphics)
count += 1

ev.Graphics.DrawString(col1, myfont, Brushes.Black, Col1_OffSet, yPos)
ev.Graphics.DrawString(col2, myfont, Brushes.Black, Col2_OffSet, yPos)
ev.Graphics.DrawString(col3, myfont, Brushes.Black, Col3_Offset, yPos)
ev.Graphics.DrawString(col4, myfont, Brushes.Black, Col4_Offset, yPos)

If count >= LinesPerPage Then
ev.HasMorePages = True
count = 0
Else
ev.HasMorePages = False
End If

End While

The above code is an example of the database while loop. When i try this only one page prints, with all of the data, in other words the data that should be printed on the second page prints over the data at the top of the first page.

The printing code looks correct its just the HasMorePages part that i cannot seem to get right.

Can any one see what Im doing wrong.

Regards
MunkeeJuice
 
Sorted my problem. I loaded all of the data that i needed to print into a dataset then, printed the data from the dataset. By using the dataset it gave me more flexability.

Regards
MunkeeJuice
 
Back
Top