It seems that you can persist in a settings file PrinterSettings and also PageSettings, they are Serializable etc. Great! Everything was going OK until I tried to persist my PageSettings and the margins. Everytime I change the margins, save the settings and then reload them back into the PageSetupDialog.PageSettings - they have been modified. Does anyone know why this happens? Is it something that the driver or Windows is doing ? Its bizarre, see below:
Here I show the dialog:
PageSetupDialog psd = new PageSetupDialog();
psd.PageSettings = MySettings.Default.pageSettings;
if (psd.ShowDialog() == DialogResult.OK)
I manually change the values to 5.
Then I save the changes:
MySettings.Default.pageSettings = psd.PageSettings;
When I reload the dialog and load in the settings from the settings file the values have changed to 2!?
UPDATE:
So just to try and expand on the problem - if we show the PageSetupDialog for the first time with default settings values which are 10 for all margins. If we inspect the values during debug then we see them represented like this:
So they are all 100, strange but I expected them to be 10 i.e. like 10mm like the dialog says, so I don t know what unit of measure 100 is pertaining to be but anyway lets assume that it correlates with 10 in the dialog.
We then edit them all to 5 in the dialog and press OK - so we get past this code:
if (psd.ShowDialog() == DialogResult.OK)
so we would expect to see on inspection of the pageSettingDialog object to see some values for the margins to be all 5 (or 50, as seems to be the case in the 10 vs 100 confusion, see above). Let s have a look at the object then:
Low and behold it s not what we were expecting, it s 20 for some bizarre reason. That s where I get stuck, I just can t work out whats going on behind the seens here. Why is it changing from 50 to 20?, why won t it keep the value I set? Hope that explains it a little bit better.