PrinterSettings

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am having problems using the Printer Dialog to set PrinterSettings,
specifically the landscape property of the DefaultPageSettings. Here's the
code:

<code>
Private Sub GetPrinter(ByRef PrinterSettings as PrinterSettings, Landscape
as Boolean)
Dim pdiag As New PrintDialog
Dim pset As New PrinterSettings
pset.DefaultPageSettings.Landscape = Landscape
pdiag.PrinterSettings = pset
If pdiag.ShowDialog() = DialogResult.OK Then
PrinterSettings = pdiag.PrinterSettings
End If
End Sub
</code>

Regardless of what printer and/or options are selected in the dialog, they
aren't in pdiag.PrinterSettings. Am I doing something wrong? Shouldn't the
options selected be in pdiag.PrinterSettings?

Thanks
 
Hi,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when you have set printer properties in
the printer dialog, the configurations cannot be seen from PrinterSettings
property. If there is any misunderstanding, please feel free to let me know.

I have tried your code and call the sub with the following code:

Dim p As New PrinterSettings
GetPrinter(p, True)

It works well on my computer, the setting that I made in the dialog box can
be get from p successfully. If that doesn't work, could you show me more
code when you call that sub? Or is my understanding to this issue correct?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi,

Based on my research, if you need to make changes to the printer settings,
you need to change the DefaultPageSettings property of a PrinterDocument
instead of the PrintDialog.PrinterSettings. Here I have made some changes
to your code. It is not recommended to use PrinterSettings as the parameter
name, because it as the name of a class.

Private Sub GetPrinter(ByRef PrinterSetting As PrinterSettings, ByVal
Landscape As Boolean)
Dim pdiag As New PrintDialog
Dim pset As New PrinterSettings
Dim doc As New PrintDocument
pdiag.Document = doc
pdiag.Document.DefaultPageSettings.Landscape = Landscape
If pdiag.ShowDialog() = DialogResult.OK Then
PrinterSetting = pdiag.PrinterSettings
End If
End Sub

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi,

This all helped me to solve a problem that I had saving and restoring
printer settings. Except that PrinterSettings has a member
DefaultPageSettings which is not being used.

I dont understand why modifying or assigning Document.PrinterSettings or
pdiag.Document.PrinterSettings
before the dialog does not change the PageSettings to the those in the
Document.PrinterSettings.DefaultPageSettings.

Why do we instead have to assign the page part of what appeard to be an
ecapsulated set of printter settings separately into
Document.DefaultPageSettings.
 
Back
Top