comment imprimer un textbox multiline
bonjour à tous
je veut imprimer le contenu d'un textbox multiline mon probléme est que sa imprime tout sur une méme ligne si quelqu'un peu m'aidé svp
voici une partie de mon code
Code:
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
|
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
' autorise le choix de la page d'impression
PrintDialog1.AllowSomePages = True
' montre le bouton d'aide
PrintDialog1.ShowHelp = True
' Fixe les propriétés du documents (impératif)
PrintDialog1.Document = docToPrint
Dim result As DialogResult = PrintDialog1.ShowDialog()
docToPrint.DefaultPageSettings.Landscape = True
' Si le résultat est bon on imprime
If (result = Windows.Forms.DialogResult.OK) Then
docToPrint.Print()
End If
End Sub
Private Sub document_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles docToPrint.PrintPage
'champs de saisie
lab1 As String = Label1.Text
Dim printFont As New System.Drawing.Font("Arial", 10, System.Drawing.FontStyle.Regular)
'rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Dim strText As String = TextBox1.Text
Dim myreader = New StringReader(strText)
Dim linesPerPage As Single = 0
Dim yPosition As Single = 0
Dim count As Integer = 0
Dim leftMargin As Single = e.MarginBounds.Left
Dim topMargin As Single = e.MarginBounds.Top
Dim line As String = Nothing
Dim printFont1 As Font = TextBox1.Font
Dim myBrush As New SolidBrush(Color.Black)
linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics)
While count < linesPerPage
line = myreader.ReadLine()
If (line Is Nothing) Then
Exit While
Else
yPosition = topMargin + count * printFont.GetHeight(e.Graphics)
e.Graphics.DrawString(line, printFont, myBrush, leftMargin, yPosition, New StringFormat())
count += 1
If count >= linesPerPage Then
e.HasMorePages = True
count = 0
End If
End If
End While
e.HasMorePages = False
myBrush.Dispose()
'champ de saisie
e.Graphics.DrawString(lab1, printFont, System.Drawing.Brushes.Black, 300, 80)
End Sub |