Bonsoir, je souhaite de l'aide car je voudrais gérer l'impression multipages pour mon appli. J'ai cherché et trouvé différentes choses sur internet notamment l'utilisation de la propriété e.hasmorepage mais j'avoue ne pas y comprendre grand chose.

Quelqu'un pourrait-il me dire comment procéder et où introduire cette propriété dans le code suivant.

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
60
61
62
63
64
65
 
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        Dim cmptBox As Single
        Dim Police1 As New Font("Book Antiqua", 10)
        Dim Police1G As New Font("Book Antiqua", 10, FontStyle.Bold)
        Dim Police2 As New Font("Book Antiqua", 12)
        Dim Police2G As New Font("Book Antiqua", 12, FontStyle.Bold)
        Dim YPos As Single = e.MarginBounds.Top
        Dim Longueur As Single
        Dim SautLigne As Single = e.Graphics.MeasureString("X", Police2G).Height
        Dim LigneParPages As Single = Int(e.MarginBounds.Height / SautLigne)
        Using MyGr As Graphics = e.Graphics
            Dim i As Single = 1
            Dim Str As String = ""
            Longueur = MyGr.MeasureString("NOM :", Police2G).Height + 10
            MyGr.DrawLine(Pens.Black, e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Right, e.MarginBounds.Top)
            MyGr.DrawLine(Pens.Black, e.MarginBounds.Left, e.MarginBounds.Top + Longueur, e.MarginBounds.Right, e.MarginBounds.Top + Longueur)
            YPos = YPos + 5
            MyGr.DrawString("NOM :", Police2G, Brushes.Black, e.MarginBounds.Left, YPos)
            Longueur = MyGr.MeasureString("NOM :", Police2G).Width + e.MarginBounds.Left
            MyGr.DrawString(Renseignements.TextBox1.Text, Police2, Brushes.Black, Longueur + 5, YPos)
            MyGr.DrawString("Prénom :", Police2G, Brushes.Black, 500, YPos)
            Longueur = MyGr.MeasureString("Prénom :", Police2G).Width + 500
            MyGr.DrawString(Renseignements.TextBox2.Text, Police2, Brushes.Black, Longueur + 5, YPos)
            YPos = YPos + (SautLigne * 2.0F)
            MyGr.DrawString("Forfait :", Police1G, Brushes.Black, e.MarginBounds.Left, YPos)
            Longueur = MyGr.MeasureString("Forfait :", Police1G).Width + e.MarginBounds.Left
            MyGr.DrawString(Renseignements.ComboBox1.Text, Police1, Brushes.Black, Longueur + 5, YPos)
            MyGr.DrawString("Observations :", Police1G, Brushes.Black, 265, YPos)
            Longueur = MyGr.MeasureString("Observations :", Police1G).Width + 265
            MyGr.DrawString(Renseignements.TextBox8.Text.Replace(Chr(10), ", "), Police1, Brushes.Black, Longueur + 5, YPos)
            YPos = YPos + (SautLigne * 2.5F)
            Longueur = MyGr.MeasureString("* * * *   P R O G R A M M E   * * * *", Police2G).Width
            MyGr.DrawString("* * * *   P R O G R A M M E   * * * *", Police2G, Brushes.Black, (e.PageBounds.Right - Longueur) / 2, YPos)
            YPos = YPos + (SautLigne * 2.5F)
            Select Case TextBox1.Text
                Case 1 : Str = "ère"
                Case Else : Str = "ème"
            End Select
            MyGr.DrawString(TextBox1.Text & Str & " Période :       du                                                  au", Police1G, Brushes.Black, e.MarginBounds.Left, YPos)
            YPos = YPos + SautLigne
            If IsNumeric(TextBox2.Text) Then
                Select Case TextBox2.Text
                    Case Is > 1
                        Longueur = MyGr.MeasureString(" ====>   X  " & TextBox2.Text & " semaines", Police1).Width + 5
                        MyGr.DrawString(" =====>   X  " & TextBox2.Text & " semaines", Police1, Brushes.Black, e.MarginBounds.Left + 35, YPos)
                        YPos = YPos + SautLigne
                    Case Else : TextBox2.Clear()
                End Select
            End If
            For cmptBox = 0 To ListBox4.Items.Count - 1
                Dim index As Integer = ListBox3.FindString(ListBox4.Items(cmptBox).ToString)
                Dim StrSeance As String = "Séance n° " & i & " :   "
                Str = ""
                Str = Str & " + " & ListBox4.Items(cmptBox).ToString()
                If index <> -1 Then
                    Str = Strings.Right(Str, Len(Str) - 3)
                    MyGr.DrawString(StrSeance & Str, Police1, Brushes.Black, e.MarginBounds.Left + 35, YPos)
                    YPos = YPos + SautLigne
                    Str = ""
                    i = i + 1
                End If
            Next
        End Using
    End Sub
Merci