PrintDialog returns always cancel

  • Thread starter Thread starter JR
  • Start date Start date
J

JR

Dim PrintDialog As New PrintDialog
Dim result As DialogResult = PrintDialog.ShowDialog()
If result = Windows.Forms.DialogResult.OK Then
'I get always cancel(2) as an result and nothing happens
end if

Why do I aways have cancel as an result. It shout popup but it doens on
vista 64

Thanxs
 
Dim PrintDialog As New PrintDialog
Dim result As DialogResult = PrintDialog.ShowDialog()
If result = Windows.Forms.DialogResult.OK Then
'I get always cancel(2) as an result and nothing happens
end if

Why do I aways have cancel as an result. It shout popup but it doens on
vista 64

Thanxs

JR,
Try This:

If PrintDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
' Code
End If

And make sure, you've one printer installed at least.
 
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-----------
 
JR said:
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-----------

It seems to be a 64 bit problem.
This code works fine with XP 32 bit but on vista 64 or XP 64 it will not

Jan
 
Back
Top