Problème de sortie d'impresion

F2ATA Messages postés 21 Date d'inscription vendredi 9 novembre 2007 Statut Membre Dernière intervention 4 février 2011 - 8 juil. 2008 à 19:15
F2ATA Messages postés 21 Date d'inscription vendredi 9 novembre 2007 Statut Membre Dernière intervention 4 février 2011 - 8 juil. 2008 à 20:13
bonjour à tous!
j'essaye d'imprimer le contenu d'une listview avec mon programme C# (Visual Studio 2005), mais lorsque je click sur le bouton imprimer, le travail d'impression démarre et rien n'apparait sur le papier.
Pour l'impression, j'utilise PrintDocument, PrintDocumentDialog et PrintPreviewDialog.

Merci de m'aider à resoudre mon problème!!!

2 réponses

MorpionMx Messages postés 3466 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 30 octobre 2008 57
8 juil. 2008 à 19:47
Salut,

Il faudrait voir le code pour la génération du PrintDocument (evenement PrintPage)

Mx
MVP C# 
0
F2ATA Messages postés 21 Date d'inscription vendredi 9 novembre 2007 Statut Membre Dernière intervention 4 février 2011
8 juil. 2008 à 20:13
J'ai essyé de voir le code mais je ne vois pas ce qui pose problème.  Je vois soumet alors la procedure afin que vous y jeter aussi un oeil, tout en espérant que vous trouverez quelque chose.



private



void
printDocument1_PrintPage(

object
sender, System.Drawing.Printing.

PrintPageEventArgs
e)
{


Font
police =

new



Font
(

"Times new Roman"
, 12);


Font
police2 =

new



Font
(

"Times new Roman"
,20);








using
(

Font
titleFont =

new



Font
(

"Times new Roman"
, 18,

FontStyle
.Bold |

FontStyle
.Underline))
{


float
titleWidth = e.Graphics.MeasureString(

"Liste des Fiches"
, titleFont).Width;e.Graphics.DrawString(

"Liste des Fiches"
, titleFont,

Brushes
.Black, 320,
50);
}





//parcours la listeview et imprime les elements






for
(

int
i = j; i < listView1.Items.Count; i++)
{
++j;
e.Graphics.DrawString(

"Nom : "
+ listView1.Items[i].SubItems[0].Text, police,

Brushes
.Black, 80, ligne + 40,

StringFormat
.GenericTypographic);ligne = ligne + 80;


e.Graphics.DrawString(

"Adresse : "
+ listView1.Items[i].SubItems[1].Text, police,

Brushes
.Black, 80, ligne,

StringFormat
.GenericTypographic);ligne = ligne + 40;


e.Graphics.DrawString(

"Code Postal : "
+ listView1.Items[i].SubItems[2].Text, police,

Brushes
.Black, 80, ligne,

StringFormat
.GenericTypographic);ligne = ligne + 40;


e.Graphics.DrawString(

"Ville : "
+ listView1.Items[i].SubItems[3].Text, police,

Brushes
.Black, 80, ligne,

StringFormat
.GenericTypographic);ligne = ligne + 40;


e.Graphics.DrawString(

"Télécopie : "
+ listView1.Items[i].SubItems[5].Text, police,

Brushes
.Black, 80, ligne,

StringFormat
.GenericTypographic);ligne = ligne + 40;


e.Graphics.DrawString(

"Téléphone : "
+ listView1.Items[i].SubItems[4].Text, police,

Brushes
.Black, 80, ligne,

StringFormat
.GenericTypographic);ligne = ligne + 40;


e.Graphics.DrawString(

"E-mail : "
+ listView1.Items[i].SubItems[6].Text, police,

Brushes
.Black, 80, ligne,

StringFormat
.GenericTypographic);ligne = ligne + 40;


e.Graphics.DrawString(

"N°SIRET : "
+ listView1.Items[i].SubItems[7].Text, police,

Brushes
.Black, 80, ligne,

StringFormat
.GenericTypographic);ligne = ligne + 40;


e.Graphics.DrawString(

"Code NAF : "
+ listView1.Items[i].SubItems[8].Text, police,

Brushes
.Black, 80, ligne,

StringFormat
.GenericTypographic);ligne = ligne + 40;


e.Graphics.DrawString(

"Effectif : "
+ listView1.Items[i].SubItems[9].Text, police,

Brushes
.Black, 80, ligne,

StringFormat
.GenericTypographic);




ligne = ligne + 40;


e.Graphics.DrawString(

"Site Web : "
+ listView1.Items[i].SubItems[10].Text, police,

Brushes
.Black, 80, ligne,

StringFormat
.GenericTypographic);


ligne = ligne + 40;




e.Graphics.DrawString(

"Présentation : "
+ listView1.Items[i].SubItems[11].Text, police,

Brushes
.Black, 80, ligne,

StringFormat
.GenericTypographic);


ligne += 40;
if
(ligne >= e.MarginBounds.Height)
break;


}


if
(j >= listView1.Items.Count)
{
e.HasMorePages =

false
;
ligne = 80;
j = 0;
}


else

{
e.HasMorePages =

true
;
ligne = 80;
}



}
0
Rejoignez-nous