Torna al Thread
Dim WithEvents pr As New PrintDocument
Dim numeroPagina As Integer
Dim mioFont As New Font(FontFamily.GenericSansSerif, 28.0F, FontStyle.Bold, GraphicsUnit.Pixel)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'--- avvio la stampa
pr.DocumentName = "Mio Documento"
pr.Print()
End Sub
Private Sub pr_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pr.PrintPage
numeroPagina += 1
Dim x As Integer = e.PageSettings.PaperSize.Width / 3
Dim y As Integer = e.PageSettings.PaperSize.Height / 2
e.Graphics.DrawString(TextBox1.Text & " pagina " & numeroPagina, mioFont, Brushes.Green, x, y)
e.HasMorePages = numeroPagina < NumericUpDown1.Value
End Sub