Ciao,
ho risolto in questa maniera:
Public Class Form1
Private WithEvents documento As New System.Drawing.Printing.PrintDocument
Private docToPrint As New Printing.PrintDocument
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
InizializzaPrintViewDialog()
'ListBox1.Visible = False
End Sub
Private Sub InizializzaPrintViewDialog()
Me.PrintPreviewDialog1.ClientSize = New System.Drawing.Size(800, 600)
Me.PrintPreviewDialog1.Location = New System.Drawing.Point(29, 29)
Me.PrintPreviewDialog1.Name = "PrintPreviewDialog1"
Me.PrintPreviewDialog1.UseAntiAlias = True
End Sub
Private Sub btnAnteprima_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnteprima.Click
PrintPreviewDialog1.Document = documento
PrintPreviewDialog1.ShowDialog()
End Sub
Private Sub document_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles documento.PrintPage
Dim printfont As New System.Drawing.Font("verdana", 10, System.Drawing.FontStyle.Regular)
e.Graphics.DrawString(Me.lblData.Text, printfont, System.Drawing.Brushes.Black, 0, 0)
e.Graphics.DrawString(Me.lblOra.Text, printfont, System.Drawing.Brushes.Black, 150, 0)
e.Graphics.DrawString(Me.lblMateriale.Text, printfont, System.Drawing.Brushes.Black, 0, 130)
e.Graphics.DrawString(Me.lblPeso.Text, printfont, System.Drawing.Brushes.Black, 150, 130)
End Sub
Private Sub btnStampa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStampa.Click
PrintDialog1.AllowSomePages = True
PrintDialog1.Document = docToPrint
If (PrintDialog1.ShowDialog() = Windows.Forms.DialogResult.OK) Then
docToPrint.Print()
End If
End Sub
Private Sub btnSetup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSetup.Click
PageSetupDialog1.PageSettings = New System.Drawing.Printing.PageSettings
PageSetupDialog1.PrinterSettings = New System.Drawing.Printing.PrinterSettings
If (PageSetupDialog1.ShowDialog() = Windows.Forms.DialogResult.OK) Then
Dim results() As Object = New Object() {PageSetupDialog1.PageSettings.Margins, PageSetupDialog1.PageSettings.PaperSize, PageSetupDialog1.PageSettings.Landscape, PageSetupDialog1.PrinterSettings.PrinterName, PageSetupDialog1.PrinterSettings.PrintRange}
lsbProprietàStampante.Items.Clear()
lsbProprietàStampante.Items.AddRange(results)
End If
End Sub
End Class