troubleshooting Question

Printing mutipul pages VB.NET 2005

Avatar of dr_dudd
dr_dudd asked on
ProgrammingVisual Basic.NET
6 Comments1 Solution1173 ViewsLast Modified:
Hi

I am current trying to design a printed report for my application. In the subroutine below i am drawing my report. However i need to know how to insert a page break / start a new page. I am populating my page with data from a sql query. once i have reached a certain number of rows i want to be able to start a new page, i have tried adding e.hasmorepages = true after if rn>25 inside my while loop but this seams to generate an infinate number of pages all the same as the first. can anybody please help?


 Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
 rn = 0
 Try
          cnafm.Open()
            Dim notes1 As SqlDataReader = getnotes.ExecuteReader
            With notes1
                If .HasRows Then
                    While .Read
                        If rn > 25 Then
?????e.hasmorepages=true?????
                            rn = 0
                        End If
                        fn = notes1(0).ToString
                        g.DrawString(fn, arial, Brushes.Black, (e.MarginBounds.Left + 2), (e.MarginBounds.Top + 30) + (rn * 40))
                        rn=rn+1
                    End While
                End If
            End With
        Finally
            cnafm.Close()
        End Try
ASKER CERTIFIED SOLUTION
NBSO_ISS

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros