Resolved printdocument.printersettings.defaultpagesettings vs printdocument.defaultpagesettings

aaaron

Well-known member
Joined
Jan 23, 2011
Messages
216
Programming Experience
10+
What is the difference between:
printdocument.printersettings.defaultpagesettings and printdocument.defaultpagesettings

and when should each be used?

Been searching what seems to me to be an obvious question, but it seems that no one else is confused enough to ask.

When I use Quickwatch to look at them they appear to have identical properties.
 
They are the same until you assign a new PageSettings object to DefaultPageSettings Property.
 
They are the same until you assign a new PageSettings object to DefaultPageSettings Property.

I must be missing something simple. Both DefaultPageSettings properties can be set with a PageSettings object..

When is it appropriate to use each.

Thanks
 
lol, I meant document.default :)
 
Both DefaultPageSettings properties can be set with a PageSettings object.
Both properties are that type but they can't both be set because PrinterSettings.DefaultPageSettings is read-only.
 
PrintDocument.DefaultPageSettings Property
Gets or sets page settings that are used as defaults for all pages to be printed.
[System.ComponentModel.Browsable(false)]
public System.Drawing.Printing.PageSettings DefaultPageSettings { get; set; }

I still haven't figured out when to use the above and when to use the below. Which one should I set?

PrinterSettings.DefaultPageSettings Property
Gets the default page settings for this printer.
public System.Drawing.Printing.PageSettings DefaultPageSettings { get; }
I just noticed the PrinterSettings.DefaultPageSettings does not have a {set;} But I've been testing (in ignorance) and have seem to have violated what the doc says. I ran the code below.

Dim pR As Printing.PrinterResolution = New Printing.PrinterResolution With {
.X = 100 + pD.DefaultPageSettings.PrinterResolution.X,
.Y = 100 + pD.DefaultPageSettings.PrinterResolution.Y
}
pD.PrinterSettings.DefaultPageSettings.PrinterResolution = pR

Below from QuickWatch (It showed 600,600 before the above code was run)
pD.PrinterSettings.DefaultPageSettings.PrinterResolution {[PrinterResolution X=700 Y=700]} System.Drawing.Printing.PrinterResolution

Comments please!
 
Last edited:
Setting means pD.DefaultPageSettings = new PageSettings()
When you do pD.DefaultPageSettings.PrinterResolution you are getting DefaultPageSettings.
 
Setting means pD.DefaultPageSettings = new PageSettings()
When you do pD.DefaultPageSettings.PrinterResolution you are getting DefaultPageSettings.
So I can change the properties that are not readonly, but can not replace the object reference.
Still, if I want to change the size do I use printdocument.printersettings.defaultpagesettings or printdocument.defaultpagesettings

thanks
 
Use PrintDocument.DefaultPageSettings to set custom settings for this document.
 
Back
Top