HasmorePages

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GGSoft
    New Member
    • Jul 2008
    • 6

    HasmorePages

    Please Can't understand how to use HasMorepages. I spent a lot of time on this task. but I have no result.
    For examle I want to print every 45 record on each new page.
    Please Rewrite the following code in correct manner.
    I dont know where to place HasmorePages=tr ue and HasmorePages=fa lse
    Code:
    Private Sub Pr_PrintReg(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pr.PrintPage
            Dim gr As Graphics = e.Graphics
            Dim i As Int32
            For i = 1 To 200
                If i Mod 45 = 0 Then e.HasMorePages = True
                gr.DrawString(i.ToString + " Square is - " + (i ^ 2).ToString, New Font("arial", 12), Brushes.Black, 100, (i Mod 45) * 25 + 50)
            Next
           e.HasMorePages = False
    End sub
    Last edited by Curtis Rutland; Aug 18 '08, 02:54 PM. Reason: Added Code Tags - Please use the # button
  • GGSoft
    New Member
    • Jul 2008
    • 6

    #2
    At least I have found solution Myself. Here is code:
    This simple solution will help to many people.

    Main logik is that, When Use e.HasMorePages = True, procedure Runs again from beginning. Use static variable to hold page number.

    Other you will understand without any problem.

    Code:
    Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
            Dim gr As Graphics = e.Graphics
            Dim reachedEnd As Boolean = False
            Dim i As Int16
            Dim Y As Int16
            Dim lastnumber As Int16
            Static page As Int16 = 0
            page += 1
            If page * 60 >= 200 Then lastnumber = 200 : reachedEnd = True Else lastnumber = page * 60
            Y = 0
            For i = (page - 1) * 60 + 1 To lastnumber
                Y += 1
                gr.DrawString(i.ToString + " Square is - " + (i ^ 2).ToString, New Font("arial", 12), Brushes.Black, 100, (Y * 18 + 50))
            Next
            If reachedEnd Then e.HasMorePages = False Else e.HasMorePages = True
        End Sub

    Sincerelly yours George Gogiava (GGSoft)
    Last edited by Curtis Rutland; Aug 18 '08, 02:54 PM. Reason: Added Code Tags - Please use the # button

    Comment

    • GGSoft
      New Member
      • Jul 2008
      • 6

      #3
      Instead of 45 Record as disscussed above I Use 60 record per page.

      Comment

      Working...