BOnjour

J'essaye d'effectuer un saut de page a l'impression avec la methode PrinPage mais pas de saut de page. Voici le bout de code.
Il detecte bien le nombre de ligne pour recommencer a la bonne place mais il ne fait pas le saut de page avec HasMorePage=true. Quelqu'un peu m'aider sur ce petit problème

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 Private Sub PrintListe_PrintPage(sender As System.Object, e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintListe.PrintPage
            Dim PF10Normal As Font = New Font("Arial", 10, FontStyle.Regular, GraphicsUnit.Point)
            Dim PF10Bold As Font = New Font("Arial", 10, FontStyle.Bold, GraphicsUnit.Point)
            Dim PF10BoldS As Font = New Font("Arial", 10, FontStyle.Bold + FontStyle.Underline, GraphicsUnit.Point)
            Dim PF9Normal As Font = New Font("Arial", 9, FontStyle.Regular, GraphicsUnit.Point)
            Dim PF7Normal As Font = New Font("Arial", 7, FontStyle.Regular, GraphicsUnit.Point)
            Dim PF16Bold As Font = New Font("Arial", 16, FontStyle.Bold, GraphicsUnit.Point)
            Dim blackPen3 As New Pen(Color.Black, 3)
            Dim blackPen1 As New Pen(Color.Black, 1)
            Dim StrFormat As New StringFormat(StringFormatFlags.NoClip)
 
            Dim Rect As Rectangle
            Dim Ligne As Integer
            Dim i As Integer
 
            Ligne = 52
 
            'Appel l'entete du document
            HeaderListe(e)
 
            Do While i < 20 'DgListe.Rows.Count
 
                  e.Graphics.DrawString(DgListe.Rows(i).Cells("NomClient").Value, PF9Normal, Brushes.Black, G_Variable.MmTop(G_Variable.ImprimanteBonTravailMargeGauche), G_Variable.MmTop(Ligne))
                  e.Graphics.DrawString(DgListe.Rows(i).Cells("TypeMachine").Value, PF9Normal, Brushes.Black, G_Variable.MmTop(G_Variable.ImprimanteBonTravailMargeGauche + 50), G_Variable.MmTop(Ligne))
 
                  StrFormat.Alignment = StringAlignment.Near
                  Rect = New Rectangle(New Point(G_Variable.MmTop(G_Variable.ImprimanteBonTravailMargeGauche + 100), G_Variable.MmTop(Ligne)), New Size(G_Variable.MmTop(70), G_Variable.MmTop(Ligne + 8)))
                  e.Graphics.DrawString(DgListe.Rows(i).Cells("DesignationMachine").Value, PF7Normal, Brushes.Black, RectangleF.op_Implicit(Rect), StrFormat)
 
                  e.Graphics.DrawString(DgListe.Rows(i).Cells("DateIn").Value, PF7Normal, Brushes.Black, G_Variable.MmTop(G_Variable.ImprimanteBonTravailMargeGauche + 170), G_Variable.MmTop(Ligne))
                  e.Graphics.DrawString(DgListe.Rows(i).Cells("DateOut").Value, PF7Normal, Brushes.Black, G_Variable.MmTop(G_Variable.ImprimanteBonTravailMargeGauche + 200), G_Variable.MmTop(Ligne))
 
                  If DgListe.Rows(i).Cells("Urgent").Value Then e.Graphics.DrawString("V", PF7Normal, Brushes.Black, G_Variable.MmTop(G_Variable.ImprimanteBonTravailMargeGauche + 227), G_Variable.MmTop(Ligne))
                  If DgListe.Rows(i).Cells("Devis").Value = True Then e.Graphics.DrawString("V", PF7Normal, Brushes.Black, G_Variable.MmTop(G_Variable.ImprimanteBonTravailMargeGauche + 237), G_Variable.MmTop(Ligne))
                  If DgListe.Rows(i).Cells("DevisSi").Value = True Then e.Graphics.DrawString("V", PF7Normal, Brushes.Black, G_Variable.MmTop(G_Variable.ImprimanteBonTravailMargeGauche + 247), G_Variable.MmTop(Ligne))
                  If DgListe.Rows(i).Cells("Garantie").Value = True Then e.Graphics.DrawString("V", PF7Normal, Brushes.Black, G_Variable.MmTop(G_Variable.ImprimanteBonTravailMargeGauche + 262), G_Variable.MmTop(Ligne))
                  e.Graphics.DrawString(DgListe.Rows(i).Cells("NumeroSav").Value, PF9Normal, Brushes.Black, G_Variable.MmTop(G_Variable.ImprimanteBonTravailMargeGauche + 282), G_Variable.MmTop(Ligne))
 
                  Ligne += 9
                  i += 1
 
                  'Saut de page
                  If Ligne >= 100 Then
                        e.HasMorePages = True
                        Ligne = 52
                  Else
                        e.HasMorePages = False
                  End If
 
            Loop
 
      End Sub
 
      Private Sub PrintListe_QueryPageSettings(sender As Object, e As System.Drawing.Printing.QueryPageSettingsEventArgs) Handles PrintListe.QueryPageSettings
 
            'Met en landscape
            e.PageSettings.Landscape = True
 
      End Sub