none
Imprimer sur 2 pages RRS feed

  • Question

  • Salut !

    J'ai un problème pour imprimer sur deux pages. En fait, le script ne passe pas à la seconde page mais j'ai les deux page l'une sur l'autre.

    La variable HD me permet de savoir ou est le texte sur la page pour les dépenses.

    If HD + 200 > CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Height) Then

    Là on arrive au if, la condition est rempli (200 est la marge pour tester (pour l'instant)).

    Page est définie en haut de la feuille en Interger et = 0.

    Si j'enlève ça :

                Else
                    e.HasMorePages = False

    Il tourne en boucle sans s'arrêter. Je ne vois pas comment faire. Pour l'impression sur une pages ça marche mais pas sur deux pages. Merci

        Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
            'Document à imprimer
            Dim I As Integer, DateBudget As String = "", HD As Integer, HR As Integer
            Dim Ligne As New StringFormat, TexteX
    
            'Titre
            For I = 0 To TSMenuItemMois.DropDownItems.Count - 1
                If TSMenuItemMois.DropDownItems(I).Image Is Nothing = False Then DateBudget = TSMenuItemMois.DropDownItems(I).Text
            Next
            For I = 0 To TSMenuItemAnnee.DropDownItems.Count - 1
                If TSMenuItemAnnee.DropDownItems(I).Image Is Nothing = False Then DateBudget &= " " & TSMenuItemAnnee.DropDownItems(I).Text
            Next
            LabelTmp.Text = "Budjet pour " & DateBudget
            LabelTmp.Font = New Font("Times New Roman", 18, FontStyle.Bold, GraphicsUnit.Point)
            TexteX = New Rectangle(0, 30, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
            Ligne.Alignment = StringAlignment.Center
            Ligne.LineAlignment = StringAlignment.Center
            e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Green, TexteX, Ligne)
    
            'Sous-titre
            LabelTmp.Text = "Dépenses :"
            LabelTmp.Font = New Font("Arial", 14, FontStyle.Bold, GraphicsUnit.Point)
            TexteX = New Rectangle(50, 65, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
            Ligne.Alignment = StringAlignment.Near
            Ligne.LineAlignment = StringAlignment.Center
            e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Red, TexteX, Ligne)
    
            'Dépenses - Haut de la page
            e.Graphics.DrawLine(Pens.Black, 50, 90, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, 90)
            LabelTmp.Text = "Dates"
            LabelTmp.Font = New Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point)
            TexteX = New Rectangle(54, 95, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
            Ligne.Alignment = StringAlignment.Near
            Ligne.LineAlignment = StringAlignment.Center
            e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.MediumBlue, TexteX, Ligne)
            LabelTmp.Text = "Libellés"
            LabelTmp.Font = New Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point)
            TexteX = New Rectangle(0, 95, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
            Ligne.Alignment = StringAlignment.Center
            Ligne.LineAlignment = StringAlignment.Center
            e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.MediumBlue, TexteX, Ligne)
            LabelTmp.Text = "Montants"
            LabelTmp.Font = New Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point)
            TexteX = New Rectangle(0, 95, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 56, LabelTmp.Height)
            Ligne.Alignment = StringAlignment.Far
            Ligne.LineAlignment = StringAlignment.Center
            e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.MediumBlue, TexteX, Ligne)
            e.Graphics.DrawLine(Pens.Black, 50, 117, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, 117)
    
            'Tableau des dépenses
            HD = 122
            For I = 0 To DGVDepenses.RowCount - 1
                If DGVDepenses.Rows(I).IsNewRow = False Then
                    LabelTmp.Text = DGVDepenses.Item(0, I).Value
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(64, HD, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Near
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Brown, TexteX, Ligne)
    
                    LabelTmp.Text = DGVDepenses.Item(1, I).Value
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(112, HD, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Near
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.DarkCyan, TexteX, Ligne)
    
                    LabelTmp.Text = DGVDepenses.Item(2, I).Value
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(0, HD, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 54, LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Far
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.DarkCyan, TexteX, Ligne)
                    e.Graphics.DrawLine(Pens.Black, 50, HD + 20, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HD + 20)
                Else
                    LabelTmp.Text = "Total"
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(64, HD, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Near
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Black, TexteX, Ligne)
    
                    LabelTmp.Text = LabelTotalDepenses.Text
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(0, HD, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 54, LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Far
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Red, TexteX, Ligne)
                    e.Graphics.DrawLine(Pens.Black, 50, HD + 20, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HD + 20)
                End If
                HD += 25
                If HD + 200 > CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Height) Then
                    HD = 122
                    e.HasMorePages = Page + 1
                Else
                    e.HasMorePages = False
                End If
            Next
    
            'Tracé des lignes verticales pour les dépenses
            e.Graphics.DrawLine(Pens.Black, 50, 90, 50, HD - 5)
            e.Graphics.DrawLine(Pens.Black, 108, 90, 108, HD - 30)
            e.Graphics.DrawLine(Pens.Black, 685, 90, 685, HD - 5)
            e.Graphics.DrawLine(Pens.Black, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, 90, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HD - 5)
    
            'Sous-titre
            LabelTmp.Text = "Ressources :"
            LabelTmp.Font = New Font("Arial", 14, FontStyle.Bold, GraphicsUnit.Point)
            TexteX = New Rectangle(50, HD + 10, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
            Ligne.Alignment = StringAlignment.Near
            Ligne.LineAlignment = StringAlignment.Center
            e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Red, TexteX, Ligne)
    
            'Ressouces - Haut de la page
            e.Graphics.DrawLine(Pens.Black, 50, HD + 33, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HD + 33)
            LabelTmp.Text = "Libellés"
            LabelTmp.Font = New Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point)
            TexteX = New Rectangle(54, HD + 40, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
            Ligne.Alignment = StringAlignment.Near
            Ligne.LineAlignment = StringAlignment.Center
            e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.MediumBlue, TexteX, Ligne)
            LabelTmp.Text = "Montants"
            LabelTmp.Font = New Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point)
            TexteX = New Rectangle(0, HD + 40, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 56, LabelTmp.Height)
            Ligne.Alignment = StringAlignment.Far
            Ligne.LineAlignment = StringAlignment.Center
            e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.MediumBlue, TexteX, Ligne)
            e.Graphics.DrawLine(Pens.Black, 50, HD + 62, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HD + 62)
    
            'Tableau des ressources
            HD += 62
            HR = HD + 6
            For I = 0 To DGVRessources.RowCount - 1
                If DGVRessources.Rows(I).IsNewRow = False Then
                    LabelTmp.Text = DGVRessources.Item(0, I).Value
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(64, HR, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Near
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Brown, TexteX, Ligne)
    
                    LabelTmp.Text = DGVRessources.Item(1, I).Value
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(0, HR, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 54, LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Far
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.DarkCyan, TexteX, Ligne)
                    e.Graphics.DrawLine(Pens.Black, 50, HR + 20, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HR + 20)
                Else
                    LabelTmp.Text = "Total"
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(64, HR, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Near
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Black, TexteX, Ligne)
    
                    LabelTmp.Text = LabelTotalRessouces.Text
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(0, HR, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 54, LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Far
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Red, TexteX, Ligne)
                    e.Graphics.DrawLine(Pens.Black, 50, HR + 20, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HR + 20)
                End If
                HR += 25
            Next
    
            'Tracé des lignes verticales pour les ressouces
            e.Graphics.DrawLine(Pens.Black, 50, HD - 29, 50, HR - 5)
            e.Graphics.DrawLine(Pens.Black, 685, HD - 29, 685, HR - 5)
            e.Graphics.DrawLine(Pens.Black, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HD - 29, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HR - 5)
        End Sub
    

    vendredi 23 octobre 2015 16:42

Réponses

  • J'ai trouvé tout seul !

    Voici mon code qui marche :

    PS j'ai déclaré la variable LimitePage à zéro avant l'aperçu.

        Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
            'Document à imprimer
            Dim I As Integer, DateBudget As String = "", HD As Integer = 0, HR As Integer = 0
            Dim Ligne As New StringFormat, TexteX
            e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
    
            'Titre
            For I = 0 To TSMenuItemMois.DropDownItems.Count - 1
                If TSMenuItemMois.DropDownItems(I).Image Is Nothing = False Then DateBudget = TSMenuItemMois.DropDownItems(I).Text
            Next
            For I = 0 To TSMenuItemAnnee.DropDownItems.Count - 1
                If TSMenuItemAnnee.DropDownItems(I).Image Is Nothing = False Then DateBudget &= " " & TSMenuItemAnnee.DropDownItems(I).Text
            Next
            LabelTmp.Text = "Budjet pour " & DateBudget
            LabelTmp.Font = New Font("Times New Roman", 18, FontStyle.Bold, GraphicsUnit.Point)
            TexteX = New Rectangle(0, 30, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
            Ligne.Alignment = StringAlignment.Center
            Ligne.LineAlignment = StringAlignment.Center
            e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Green, TexteX, Ligne)
    
            'Sous-titre
            LabelTmp.Text = "Dépenses :"
            LabelTmp.Font = New Font("Arial", 14, FontStyle.Bold, GraphicsUnit.Point)
            TexteX = New Rectangle(50, 65, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
            Ligne.Alignment = StringAlignment.Near
            Ligne.LineAlignment = StringAlignment.Center
            e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Red, TexteX, Ligne)
    
            'Dépenses - Haut de la page
            e.Graphics.DrawLine(Pens.Black, 50, 90, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, 90)
            LabelTmp.Text = "Dates"
            LabelTmp.Font = New Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point)
            TexteX = New Rectangle(54, 95, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
            Ligne.Alignment = StringAlignment.Near
            Ligne.LineAlignment = StringAlignment.Center
            e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.MediumBlue, TexteX, Ligne)
            LabelTmp.Text = "Libellés"
            LabelTmp.Font = New Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point)
            TexteX = New Rectangle(0, 95, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
            Ligne.Alignment = StringAlignment.Center
            Ligne.LineAlignment = StringAlignment.Center
            e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.MediumBlue, TexteX, Ligne)
            LabelTmp.Text = "Montants"
            LabelTmp.Font = New Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point)
            TexteX = New Rectangle(0, 95, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 56, LabelTmp.Height)
            Ligne.Alignment = StringAlignment.Far
            Ligne.LineAlignment = StringAlignment.Center
            e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.MediumBlue, TexteX, Ligne)
            e.Graphics.DrawLine(Pens.Black, 50, 117, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, 117)
    
            'Tableau des dépenses
            HD = 122
            For I = LimitePage To DGVDepenses.RowCount - 1
                If DGVDepenses.Rows(I).IsNewRow = False Then
                    LabelTmp.Text = DGVDepenses.Item(0, I).Value
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(64, HD, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Near
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Brown, TexteX, Ligne)
    
                    LabelTmp.Text = DGVDepenses.Item(1, I).Value
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(112, HD, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Near
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.DarkCyan, TexteX, Ligne)
    
                    LabelTmp.Text = DGVDepenses.Item(2, I).Value
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(0, HD, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 54, LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Far
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.DarkCyan, TexteX, Ligne)
                    e.Graphics.DrawLine(Pens.Black, 50, HD + 20, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HD + 20)
                Else
                    LabelTmp.Text = "Total"
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(64, HD, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Near
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Black, TexteX, Ligne)
    
                    LabelTmp.Text = LabelTotalDepenses.Text
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(0, HD, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 54, LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Far
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Red, TexteX, Ligne)
                    e.Graphics.DrawLine(Pens.Black, 50, HD + 20, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HD + 20)
                End If
                HD += 25
                If LimitePage = 37 Then
                    'Tracé des lignes verticales pour les dépenses
                    e.Graphics.DrawLine(Pens.Black, 50, 90, 50, HD - 5)
                    e.Graphics.DrawLine(Pens.Black, 108, 90, 108, HD - 5)
                    e.Graphics.DrawLine(Pens.Black, 685, 90, 685, HD - 5)
                    e.Graphics.DrawLine(Pens.Black, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, 90, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HD - 5)
    
                    'Page
                    LabelTmp.Text = "Page " & Page & "/2"
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(0, 1100, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 54, LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Far
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Black, TexteX, Ligne)
                    Page += 1
                    e.HasMorePages = True
                    LimitePage += 1
                    Return
                End If
                LimitePage += 1
            Next
    
            'Tracé des lignes verticales pour les dépenses
            e.Graphics.DrawLine(Pens.Black, 50, 90, 50, HD - 5)
            e.Graphics.DrawLine(Pens.Black, 108, 90, 108, HD - 30)
            e.Graphics.DrawLine(Pens.Black, 685, 90, 685, HD - 5)
            e.Graphics.DrawLine(Pens.Black, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, 90, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HD - 5)
    
            'Sous-titre
            LabelTmp.Text = "Ressources :"
            LabelTmp.Font = New Font("Arial", 14, FontStyle.Bold, GraphicsUnit.Point)
            TexteX = New Rectangle(50, HD + 10, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
            Ligne.Alignment = StringAlignment.Near
            Ligne.LineAlignment = StringAlignment.Center
            e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Red, TexteX, Ligne)
    
            'Ressouces - Haut de la page
            e.Graphics.DrawLine(Pens.Black, 50, HD + 33, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HD + 33)
            LabelTmp.Text = "Libellés"
            LabelTmp.Font = New Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point)
            TexteX = New Rectangle(54, HD + 40, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
            Ligne.Alignment = StringAlignment.Near
            Ligne.LineAlignment = StringAlignment.Center
            e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.MediumBlue, TexteX, Ligne)
            LabelTmp.Text = "Montants"
            LabelTmp.Font = New Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point)
            TexteX = New Rectangle(0, HD + 40, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 56, LabelTmp.Height)
            Ligne.Alignment = StringAlignment.Far
            Ligne.LineAlignment = StringAlignment.Center
            e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.MediumBlue, TexteX, Ligne)
            e.Graphics.DrawLine(Pens.Black, 50, HD + 62, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HD + 62)
    
            'Tableau des ressources
            HD += 62
            HR = HD + 6
            For I = 0 To DGVRessources.RowCount - 1
                If DGVRessources.Rows(I).IsNewRow = False Then
                    LabelTmp.Text = DGVRessources.Item(0, I).Value
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(64, HR, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Near
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Brown, TexteX, Ligne)
    
                    LabelTmp.Text = DGVRessources.Item(1, I).Value
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(0, HR, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 54, LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Far
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.DarkCyan, TexteX, Ligne)
                    e.Graphics.DrawLine(Pens.Black, 50, HR + 20, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HR + 20)
                Else
                    LabelTmp.Text = "Total"
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(64, HR, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width), LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Near
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Black, TexteX, Ligne)
    
                    LabelTmp.Text = LabelTotalRessouces.Text
                    LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
                    TexteX = New Rectangle(0, HR, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 54, LabelTmp.Height)
                    Ligne.Alignment = StringAlignment.Far
                    Ligne.LineAlignment = StringAlignment.Center
                    e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Red, TexteX, Ligne)
                    e.Graphics.DrawLine(Pens.Black, 50, HR + 20, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HR + 20)
                End If
                HR += 25
            Next
    
            'Tracé des lignes verticales pour les ressouces
            e.Graphics.DrawLine(Pens.Black, 50, HD - 29, 50, HR - 5)
            e.Graphics.DrawLine(Pens.Black, 685, HD - 29, 685, HR - 5)
            e.Graphics.DrawLine(Pens.Black, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HD - 29, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 50, HR - 5)
    
            'Page
            LabelTmp.Text = "Page " & Page & "/2"
            LabelTmp.Font = New Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point)
            TexteX = New Rectangle(0, 1100, CInt(PrintDocument1.DefaultPageSettings.PrintableArea.Width) - 54, LabelTmp.Height)
            Ligne.Alignment = StringAlignment.Far
            Ligne.LineAlignment = StringAlignment.Center
            e.Graphics.DrawString(LabelTmp.Text, LabelTmp.Font, Brushes.Black, TexteX, Ligne)
        End Sub
    

    vendredi 23 octobre 2015 19:49