PageSetupDialog bug!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Amjad

    #1

    PageSetupDialog bug!

    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.PrintPara meters.PrintDoc ument()
    PageSetupDialog .Document = pd
    If PageSetupDialog .ShowDialog = DialogResult.OK Then
    MsgBox (PageSetupDialo g.PageSettings. Margins)
    End If

    Any help is appreciated
  • Amjad

    #2
    RE: PageSetupDialog bug!

    It's a bug in the control as I thought. Check out what Microsoft says about it:

    BUG: The Margin Value Decreases Every Time PageSetupDialog Is Displayed
    Microsoft Support is here to help you with Microsoft products. Find how-to articles, videos, and training for Microsoft Copilot, Microsoft 365, Windows 11, Surface, and more.



    "Amjad" wrote:
    [color=blue]
    > 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.PrintPara meters.PrintDoc ument()
    > PageSetupDialog .Document = pd
    > If PageSetupDialog .ShowDialog = DialogResult.OK Then
    > MsgBox (PageSetupDialo g.PageSettings. Margins)
    > End If
    >
    > Any help is appreciated[/color]

    Comment

    • Carlos Barrera

      #3
      RE: PageSetupDialog Millimeter Bug

      I solve it this way:

      private void pageSetup( )
      {
      PageSetupDialog psd = new PageSetupDialog ( );
      psd.Document = this.printDocum ent;
      Margins originalMargins = psd.Document.De faultPageSettin gs.Margins;

      if(System.Globa lization.Region Info.CurrentReg ion.IsMetric)
      {
      psd.Document.De faultPageSettin gs.Margins = PrinterUnitConv ert.Convert(psd .
      Document.Defaul tPageSettings.M argins, PrinterUnit.Dis play, PrinterUnit.
      TenthsOfAMillim eter);
      }
      DialogResult result = psd.ShowDialog( );
      if ( result != DialogResult.OK )
      {
      psd.Document.De faultPageSettin gs.Margins = originalMargins ;
      }
      }

      Comment

      Working...