Bonjour à tous...
Je suis à la recherche depuis quelques jours pour trouver une méthode simple
pour imprimer un RichTextBox.
Je crois en avoir trouvé une qui se trouve sur ce site
[ Lien ]
J'ai donc inclu un second projet dans mon programme et tout semble OK
sauf sur cette ligne de code:
checkPrint = txtFinal.Print(checkPrint, txtFinal.TextLength, e)
Ca dit Print is not a member of 'System.Windows.Forms.RichTextBox'
Pourquoi ca me dit cela et quand j'essai le code provenant du site internet ca fonctionne très bien ?
Voici le code que j'utilise pour le moment...
Merci de votre aide
Private Sub ImpressionToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImpressionToolStripMenuItem.Click
PrintDialog1.Document = PrintDocument1
If PrintDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
PrintDocument1.Print()
End If
End Sub
Private Sub PrintDocument1_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.BeginPrint
' Adapted from Microsoft's example for extended richtextbox control
'
checkPrint = 0
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
' Adapted from Microsoft's example for extended richtextbox control
'
' Print the content of the RichTextBox. Store the last character printed.
checkPrint = txtFinal.Print(checkPrint, txtFinal.TextLength, e)
' Look for more pages
If checkPrint < txtFinal.TextLength Then
e.HasMorePages = True
Else
e.HasMorePages = False
End If
End Sub