How do you select a specific printer from the PrintPreviewDialog?

G

Guest

Is there anyway to hook the PrintDialog to the printer icon on the
PrintPreviewDialog?

I know that you can print a document using the PrintDialog but it does not
allow previewing and the PrintPreview dialog does not allow you to select a
printer - is there a good and simple way to get around these problems.

My users would like to select a specific printer while looking at the
Preview window.
 
L

Leonardo

Darrell Wesley said:
Is there anyway to hook the PrintDialog to the printer icon on the
PrintPreviewDialog?

I know that you can print a document using the PrintDialog but it does not
allow previewing and the PrintPreview dialog does not allow you to select
a
printer - is there a good and simple way to get around these problems.

My users would like to select a specific printer while looking at the
Preview window.

Public Class PrintDoc
Inherits PrintDocument

Public IsPreview As Boolean
Public Dlg As PrintPreviewDialog
Public PrvPrintFromMetafiles As Boolean

Private DirectPrint As Boolean
Private LastPage As Integer
Private WithEvents pdmf As PrintDocument
Private pageInfo As PreviewPageInfo()
..........


Protected Overrides Sub OnBeginPrint(ByVal e As
System.Drawing.Printing.PrintEventArgs)
'Si se pulsa el botón print desde PrintPreviewDialog, Selección
páginas
If IsPreview = False AndAlso DirectPrint = False Then
PrinterSettings.MinimumPage = 1
PrinterSettings.MaximumPage = LastPage
PrinterSettings.FromPage = Dlg.PrintPreviewControl.StartPage + 1
If (New PageSel(PrinterSettings)).ShowDialog(Dlg) =
DialogResult.Cancel Then e.Cancel = True : Exit Sub
If PrvPrintFromMetafiles AndAlso PrinterSettings.PrintRange =
PrintRange.SomePages Then
Dim fi As FieldInfo =
GetType(PrintPreviewControl).GetField("pageInfo", BindingFlags.NonPublic Or
BindingFlags.Instance Or BindingFlags.Public)
pageInfo = CType(fi.GetValue(Dlg.PrintPreviewControl), Object)
pdmf = New PrintDocument
pdmf.PrinterSettings = PrinterSettings
Page = PrinterSettings.FromPage - 1
pdmf.Print()
pdmf = Nothing
pageInfo = Nothing
e.Cancel = True
Exit Sub
End If
End If
MyBase.OnBeginPrint(e)


Sustituye PageSel por PrintDialog...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top