IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

impression avec PrintPage [Débutant]


Sujet :

VB.NET

  1. #1
    Membre éprouvé Avatar de thierry007
    Homme Profil pro
    Autodidacte
    Inscrit en
    Août 2006
    Messages
    876
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Autodidacte
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2006
    Messages : 876
    Par défaut impression avec PrintPage
    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

  2. #2
    Modérateur
    Avatar de Sankasssss
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2006
    Messages
    1 842
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Novembre 2006
    Messages : 1 842
    Par défaut
    Bonjour,

    tu comprends mal l'utilisation du hasmorepage, ca ne veut pas dire saut de page mais "il y a encore des pages" donc quand il est à true, a chaque fois qu'on sort de la méthode, elle est rappelée, quand on le met a false elle n'est plus rappelée.

    un petit exemple sur MSDN

    et une petite discussion sur dvp

    ton code devrait ressembler a un truc du genre (adapté vite fait, y'a moyen de faire beaucoup mieux)

    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
     
     
    private i As Integer = 0
    private Ligne As Integer
    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
     
     
     
                Ligne = 52
     
                'Appel l'entete du document
                if i = 0 then 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
                            Exit Sub
                      Else
                            e.HasMorePages = False
                      End If
     
                Loop
     
                if e.HasMorePages = False then i = 0
     
          End Sub

  3. #3
    Membre éprouvé Avatar de thierry007
    Homme Profil pro
    Autodidacte
    Inscrit en
    Août 2006
    Messages
    876
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Autodidacte
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2006
    Messages : 876
    Par défaut
    Merci Sankassss

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
      'Saut de page
                      If Ligne >= 100 Then
                            e.HasMorePages = True
                            Exit Sub
                      Else
                            e.HasMorePages = False
                      End If
    le 'exit sub '
    et le if hasMorgePage=false then

    Le pire c'est que je me suis inspirer d'un code déjà fait et je l'ai tellement relu que je suis passé au dessus de ces con....

    enfin soit grand merci

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème d'impression avec CUPS
    Par piff62 dans le forum Applications et environnements graphiques
    Réponses: 2
    Dernier message: 14/02/2005, 11h46
  2. Pbl d'impression avec le turbo pascal
    Par leboss38 dans le forum Turbo Pascal
    Réponses: 4
    Dernier message: 07/12/2004, 14h06
  3. Impression avec le composant TRvSystem
    Par tarbala dans le forum Composants VCL
    Réponses: 3
    Dernier message: 02/10/2004, 17h03
  4. impression avec quickreport
    Par k_boy dans le forum Bases de données
    Réponses: 4
    Dernier message: 14/06/2004, 09h06
  5. Probleme d'impression avec la méthode TForm->Print()
    Par Kid Icarus dans le forum C++Builder
    Réponses: 13
    Dernier message: 31/07/2002, 14h26

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo