Bonjour,
J'arrive à imprimer (papier) mais j'ai deux problèmes :
-1- Comment effectuer un sauf de page (ascii 10)
-2- Comment in fine décharger l'objet graphique ?
Voici mon code :
Merci beaucoup, cordialement.
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 Option Explicit On Public Class Form1 Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ListBox1.Items.Clear() ' chargement ListBox1.Items.Add("Maître Corbeau sur un arbre perché") ListBox1.Items.Add("Tenait don son bec un fromage") ListBox1.Items.Add("Maître Renard par l'odeur alléchée") ListBox1.Items.Add("Lui tint à peu près ce langage") ListBox1.Items.Add("Eh bonjour Monsieur du Corbeau") ListBox1.Items.Add("Que vous êtes jolie, que vous me semblez beau") End Sub Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage Dim i As Integer Dim ligne As String = "" For i = 0 To 2 'ListBox1.Items.Count - 1 ligne = ligne & ListBox1.Items(i) & vbCrLf Next i ' ' SAUT DE PAGE ? ' For i = 3 To ListBox1.Items.Count - 1 ligne = ligne & ListBox1.Items(i) & vbCrLf Next i e.Graphics.DrawString(ligne, New Font("Courier New", 12, FontStyle.Regular), Brushes.Black, 10, 10) End Sub Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' bouton : impression PrintDocument1.Print() PrintDocument1.Dispose() ' DECHARGEMENT DE E = Graphics.DrawString ??? End Sub
.
Partager