Boucle For dans boucle While pour impression sur plusieurs pages ??!!

cs_gnes Messages postés 10 Date d'inscription mardi 12 avril 2005 Statut Membre Dernière intervention 4 juillet 2005 - 1 juil. 2005 à 16:18
cs_gnes Messages postés 10 Date d'inscription mardi 12 avril 2005 Statut Membre Dernière intervention 4 juillet 2005 - 4 juil. 2005 à 08:35
Salut, j'ai un gros souci avec mon application !!!!!!!!! Je fais une impression d'une liste, et ma liste est très longue, Pour mon impression, il ne me sort qu'une feuille. Est ce que quelqu'un peut m'aider à y voir plus claire !! C'est très urgent !!
voila mon bout de code :


Dim LinesPerPage
As
Single = 0



Dim yPos
As
Single = 0



Dim count
As
Integer = 0



Dim leftMargin
As
Single = e.MarginBounds.Left



Dim topMargin
As
Single = e.MarginBounds.Top



Dim sNom, sPrenom, sOrg, sTel, sFax
As
String



Dim total, pos, TotalPers
As
Integer



Dim ligne = 0



Dim Line
As
String =
Nothing



'calcul le nombre de lignes par pages


LinesPerPage = e.MarginBounds.Height / Font.GetHeight(e.Graphics)


ligne =
CType(MultiListboxPersonnalite.SelectedIndex,
Integer)


total = MultiListboxPersonnalite.Items.Count



While count < LinesPerPage


TotalPers = LblCountListGe.Text



'Titre


e.Graphics.DrawString("PERSONNALITES",
New Font("Arial", 13, FontStyle.Regular), Brushes.Black, 480, 20)



'nombre de contacts


e.Graphics.DrawString("(" & TotalPers & ")",
New Font("Arial", 13, FontStyle.Regular), Brushes.Black, 640, 20)


e.Graphics.DrawString("Nom",
New Font("Arial", 11, FontStyle.Regular), Brushes.Black, 30, 50)


e.Graphics.DrawString("Prénom",
New Font("Arial", 11, FontStyle.Regular), Brushes.Black, 200, 50)


e.Graphics.DrawString("Organisme",
New Font("Arial", 11, FontStyle.Regular), Brushes.Black, 400, 50)


e.Graphics.DrawString("Téléphone",
New Font("Arial", 11, FontStyle.Regular), Brushes.Black, 800, 50)


e.Graphics.DrawString("Fax",
New Font("Arial", 11, FontStyle.Regular), Brushes.Black, 950, 50)


pos = 75



For ligne = ligne
To total - 1



'récupère les informations


sNom =
CType(
CType(
CType(MultiListboxPersonnalite.Items(ligne),
Object), System.Data.DataRowView).Row, System.Data.DataRow).ItemArray(3).ToString


sPrenom =
CType(
CType(
CType(MultiListboxPersonnalite.Items(ligne),
Object), System.Data.DataRowView).Row, System.Data.DataRow).ItemArray(4).ToString


sOrg =
CType(
CType(
CType(MultiListboxPersonnalite.Items(ligne),
Object), System.Data.DataRowView).Row, System.Data.DataRow).ItemArray(16).ToString


sTel =
CType(
CType(
CType(MultiListboxPersonnalite.Items(ligne),
Object), System.Data.DataRowView).Row, System.Data.DataRow).ItemArray(22).ToString


sFax =
CType(
CType(
CType(MultiListboxPersonnalite.Items(ligne),
Object), System.Data.DataRowView).Row, System.Data.DataRow).ItemArray(25).ToString


e.Graphics.DrawString(sNom & ControlChars.Tab & ControlChars.Tab,
New Font("Arial", 9, FontStyle.Regular), Brushes.Black, 30, pos)


e.Graphics.DrawString(sPrenom & ControlChars.Tab & ControlChars.Tab,
New Font("Arial", 9, FontStyle.Regular), Brushes.Black, 200, pos)


e.Graphics.DrawString(sOrg & ControlChars.Tab & ControlChars.Tab,
New Font("Arial", 9, FontStyle.Regular), Brushes.Black, 400, pos)


e.Graphics.DrawString(sTel & ControlChars.Tab & ControlChars.Tab,
New Font("Arial", 9, FontStyle.Regular), Brushes.Black, 800, pos)


e.Graphics.DrawString(sFax & ControlChars.CrLf,
New Font("Arial", 9, FontStyle.Regular), Brushes.Black, 950, pos)


pos = pos + 25


count += 1



If pos > 1040
Then


Line = pos



Exit
While



End
If



Next ligne



End
While



'si plusieurs pages



If
Not (Line
Is
Nothing)
Then


e.HasMorePages =
True



Else


e.HasMorePages =
False



End
If



Mais lorsque je mets : le bout de code pour indiquer qu'il y a plusieurs pages, l'impression ne se fait plus.

5 réponses

Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
1 juil. 2005 à 17:10
For ligne = ligne
To total - 1



cette boucle ne se fera qu'une fois,

ligne va atteindre la valeur total en fin de boucle, et étant donné que
total n'est pas changé à l'intérieur de la boucle, au prochain passage
la boucle For ne se fera plus.



t'es sur que c'est pas plutôt:

For ligne = 1
To total - 1



ou alors il faudrait que total soit cumulé




Daniel
0
cs_gnes Messages postés 10 Date d'inscription mardi 12 avril 2005 Statut Membre Dernière intervention 4 juillet 2005
1 juil. 2005 à 17:27
Oui au début j'avais mis For ligne = 0 to total -1. Après j'ai mis ligne, car je voulais que ca boucle dessus, mais je dois mal m'y prendre. Mais le probleme, c'est qu'il n'atteint pas le total donc c'est pourquoi il doit imprimer la suite de la liste sur une autre page. mais ca ne marche pas, je ne sais pas du tout comment m'y prendre la.
0
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
1 juil. 2005 à 17:41
a gnes > pas pu m'empecher !



il ya aussi la sortie de boucle quand pos dépasse 1040

ce serait pas plutôt: Exit For



If pos > 1040 Then

Line = pos

Exit For

End If

Daniel
0
cs_gnes Messages postés 10 Date d'inscription mardi 12 avril 2005 Statut Membre Dernière intervention 4 juillet 2005
1 juil. 2005 à 21:59
Ah oui, ca peut etre une solution, c'est pi etre sa que j'ai loupé. mais j'avais une question : pourquoi lors que je mets le e.HasMorePages = TRUE bah l'impression ne se lance pas du tout, mais le nombre de pages à imprimer s'incrémente mais ne s'arrete pas?? voila, j'aimerais comprendre ceci.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_gnes Messages postés 10 Date d'inscription mardi 12 avril 2005 Statut Membre Dernière intervention 4 juillet 2005
4 juil. 2005 à 08:35
Cela ne marche toujours pas !!!!!!!!!!! Quelqu'un a-t-il une solution pour m'aider !!!!!!!!!!!!!!!! C'est très urgent !!!!
0
Rejoignez-nous