When I first wrote Year Chart (before I decided to publish it online) the printing seemed so easy – a print dialog, print preview dialog and a page setup dialog. I defaulted the margins to half an inch and had the Year Chart panel draw onto the printer page. Simple!
This worked fine in my original version but when I started to prepare the rewritten version 0.2 for publication I noticed a problem during testing: when I set the regional settings to use the Metric system – using centimetres to define the margin sizes, the margins were all wrong. With the U.S. system (inches) I had set the default margin to 0.5 inches without a problem. But, with the metric system, leaving the sizes the same, each time the Page Setup dialog is displayed, the margins change – first 5mm, then 2mm, then 0.8mm and so on. Not good!
After a lot of searching on the internet I found nothing apart from several people asking the same question. Very disappointing! So I spent a bit of time investigating all the methods and properties of the various printer classes and I finally came across the “EnableMetric” property on the PageSetupDialog. This is false by default, but when I set it to true then problem went away and the 0.5 inch margins are correctly displayed as a metric 12.7mm – and still have that value each time the dialog is opened (unless you change it).
It is worth noting that this setting also ensures the margins are handled properly whether the Regional settings are Metric or U.S. systems. So it’s best to set it to true and forget about it.
Now, maybe I’m missing something here, but… never mind, it’s probably just for backward compatibility! What is more annoying is that I failed to see it sooner given that it is perfectly visible on the property sheet when you select the PageSetupDialog instance in design view.
Have a look at PageSetupDialog.EnableMetric Property (System.Windows.Forms) for more details.
Oh, I’ve had a load more problems writing version 0.3 of Kajabity Year Chart (due out soon) so there will be a few more posts on that over the next couple of weeks.