kimiraikkonen said:
JR,
Try This:
If PrintDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
' Code
End If
And make sure, you've one printer installed at least.
sorry,
won't work
still returns cancel
I also added like you suggested a control of the printers. that returns
(like it shout) 3
this is the complete routine
'---------start code-----------
Public Sub sSetPrintVB(ByVal prn As Object)
Dim dlgPrintDialog As New PrintDialog
Try
Dim nPrinterCount As Integer =
System.Drawing.Printing.PrinterSettings.InstalledPrinters.Count
If nPrinterCount > 0 Then
Dim dlgPrintPreview As New PrintPreviewDialog
dlgPrintDialog.PrinterSettings = prn.PrinterSettings
dlgPrintDialog.Document = prn
prn.PrinterSettings = dlgPrintDialog.PrinterSettings
If dlgPrintDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
'here i never comes because I always have cancel
With dlgPrintPreview
.Document = prn
.WindowState = FormWindowState.Maximized
.ShowInTaskbar = False
dlgPrintPreview.PrintPreviewControl.AutoZoom = False
dlgPrintPreview.PrintPreviewControl.Zoom = 1
.ShowDialog()
End With
End If
Else
MsgBox("No printer")
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub 'sSetPrintVB
'---------end code-----------