help with .HasMorePages and non-iterating printing

K

Kyle Walz

I'm working on an app where each page is a like a form (not Windows
form) with a set format. Using MSVB.NET 2003 with 1.1 framework.
Here's some code:

Private Sub PrintText(ByVal sender As Object, ByVal ev As
PrintPageEventArgs)
Dim brush As Brush = New SolidBrush(Color.Black)
Dim font As Font = New Font("Arial", 10, FontStyle.Regular)

' first page
ev.Graphics.DrawString(Label1.Text, font, brush, 60, 60)
ev.Graphics.DrawString(TextBox1.Text, font, brush, 420, 60)
' etc...
ev.Graphics.DrawString(Label37.Text, font, brush, 60, 840)
ev.Graphics.DrawString(TextBox36.Text, font, brush, 420, 840)

' tried a few different things here, I know this doesn't work :)
ev.HasMorePages = False
ev.HasMorePages = True

' second page
ev.Graphics.DrawString(Label40.Text, font, brush, 280, 60)
ev.Graphics.DrawString(Label41.Text, font, brush, 480, 60)
' etc...
ev.Graphics.DrawString(TextBox49.Text, font, brush, 280, 570)
ev.Graphics.DrawString(Label54.Text, font, brush, 480, 570)

ev.HasMorePages = False
End Sub

Each page is different with various column-n-row setups. Looking for
a way to say "next page" and keep marching to a new page's format.
Thanks for any help.

Kyle
 
K

Kyle Walz

(Haven't seen any replies yet, but updating progress.)
I have a gnarly (makes me feel dirty) workaround that'll do for
development. Please offer suggestions on a more elegant way to
accomplish multiple page printing.

//from print button action event
Dim result As DialogResult = PrintDialog1.ShowDialog()
If result = DialogResult.OK Then
For i = 1 To 2
PrintDoc.Print()
Next
End If

//printpage sub
Private Sub PrintText(ByVal sender As Object, _
ByVal ev As PrintPageEventArgs)
Dim brush As Brush = New SolidBrush(Color.Black)
Dim pen As New System.Drawing.Pen(System.Drawing.Color.Black)
Dim font As Font = New Font("Arial", 10, FontStyle.Regular)
Dim font1 As Font = New Font("Arial", 10, FontStyle.Bold)

' DrawString(string, brush, x, y)

If (i = 1) Then page_one(ev, brush, pen, font, font1)
If (i = 2) Then page_two(ev, brush, pen, font, font1)

End Sub

The ev.HasMorePages = False is at the end of each page_number() sub.
All the Graphics.DrawString calls are in the page_number subs to keep
everything tidy.

Thanks for any help.

Kyle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top