Spread Windows Forms 10.0 Product Documentation
Adding Support for High DPI Settings

Spread supports high DPI settings provided that the application has high DPI support enabled.

Refer to Microsoft's web site for more information about enabling DPI support for your application.

You can refer to the following steps for a general example of how to enable DPI support in .NET 4.5.2.

  1. Use the Windows API with the following code.
    Code
    Copy Code
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            SetProcessDPIAware();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
     
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        public extern static IntPtr SetProcessDPIAware();
    }
    

    Note: The SetProcessDPIAware API must be called before any window is created; otherwise, a window created before using this API will have the wrong size and font.

  2. Add Spread code:
    Code
    Copy Code
    //add code in InitializeComponent() of cs file
    this.fpSpread1.SpreadScaleMode = FarPoint.Win.Spread.ScaleMode.ZoomDpiSupport;
    this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
    
  3. Enable Windows Forms High DPI support by adding code to the App.config.
    Code
    Copy Code
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <appSettings>
        <add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
      </appSettings>
    </configuration>
    

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options | Documentation Feedback