PageSetupDialog bug!

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

Guest

I use the PageSetupDialog box to allow the user to change the page margins
before printing. The problem is when I open the dialog box and type in margin
values in millimeters (as it says in the group border title), click on the OK
button, and then open the dialog box again, I find that all the margin values
were divided by 2.54.

Basically, every time I open that Dialog box and click on OK, all the margin
values get divided by 2.54.

I know that this is a metric-imperial unit problem, but I don't know how to
fix it. I have used the following code to open the dialog box:

Dim pd As PrintDocument = C1grd.PrintParameters.PrintDocument()
PageSetupDialog.Document = pd
If PageSetupDialog.ShowDialog = DialogResult.OK Then
MsgBox (PageSetupDialog.PageSettings.Margins)
End If

Any help is appreciated
 
I solve it this way:

private void pageSetup( )
{
PageSetupDialog psd = new PageSetupDialog( );
psd.Document = this.printDocument;
Margins originalMargins = psd.Document.DefaultPageSettings.Margins;

if(System.Globalization.RegionInfo.CurrentRegion.IsMetric)
{
psd.Document.DefaultPageSettings.Margins = PrinterUnitConvert.Convert(psd.
Document.DefaultPageSettings.Margins, PrinterUnit.Display, PrinterUnit.
TenthsOfAMillimeter);
}
DialogResult result = psd.ShowDialog();
if ( result != DialogResult.OK)
{
psd.Document.DefaultPageSettings.Margins = originalMargins;
}
}
 

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

Back
Top