Change Default Unit from code

How can I change Default used Unit from c# code as it can be done for DefaultPaperSize?

Thank you in advance.

Comments

  • edited 3:12PM
    FastReport.ReportPage Page1 = new FastReport.ReportPage();
    Page1.Name = "Page1";
    Page1.PaperWidth = 215.9f;    // millimeter => 21.59 cm
    Page1.PaperHeight = 139.7f;    // millimeter => 13.97 cm
    Page1.LeftMargin = 20f;    // millimeter => 2 cm
    Page1.RightMargin = 20f;    // millimeter => 2 cm
    Page1.FirstPageSource = 15;    // automatically select
    Page1.OtherPagesSource = 15;    // automatically select
    
  • edited 3:12PM
    I mean that on UI in View menu there is a Units options and in View->Options->ReportPage.
    Is there way to change this option from code? (please see attachment)
  • edited February 2019
    >
    using (var report = new FastReport.Report())
    {
        using (var designer = new FastReport.Design.StandardDesigner.DesignerForm(false))
        {
            designer.ShowInTaskbar = true;
            designer.Designer.Report = report;
    
            var ribbon = designer.Controls[2] as FastReport.DevComponents.DotNetBar.RibbonControl;
            var panel = ribbon.Controls[3] as FastReport.DevComponents.DotNetBar.RibbonPanel;
            var bar = panel.Controls[0] as FastReport.DevComponents.DotNetBar.RibbonBar;
            var button = bar.Items[3] as FastReport.DevComponents.DotNetBar.ButtonItem;
            var buttonMilli = button.SubItems[0] as FastReport.DevComponents.DotNetBar.ButtonItem;
            var buttonCenti = button.SubItems[1] as FastReport.DevComponents.DotNetBar.ButtonItem;
            var buttonInch = button.SubItems[2] as FastReport.DevComponents.DotNetBar.ButtonItem;
            var buttonHundredOfInch = button.SubItems[3] as FastReport.DevComponents.DotNetBar.ButtonItem;
    
            // milli or centi or inch or hundred of inch
            buttonMilli.RaiseClick();
            //buttonCenti.RaiseClick();
            //buttonInch.RaiseClick();
            //buttonHundredOfInch.RaiseClick();
    
            designer.ShowDialog();
        }
    }
    
  • Hello!

    The default units of measurement for the designer's UI (View -> Options -> ReportPage -> Units) are stored in the FastReport.config configuration file. They can be set programmatically before opening the designer using Config.Root:

    var designerNode = FastReport.Utils.Config.Root.FindItem(“Designer”);
    var reportNode = designerNode.FindItem(“Report”);
    reportNode.SetProp(“Units”, “Millimeters”); // or Centimeters, Inches, HundrethsOfInch
    
This discussion has been closed.