Winform.AutoSizeHelper 1.0.7

There is a newer version of this package available.
See the version list below for details.
dotnet add package Winform.AutoSizeHelper --version 1.0.7                
NuGet\Install-Package Winform.AutoSizeHelper -Version 1.0.7                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Winform.AutoSizeHelper" Version="1.0.7" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Winform.AutoSizeHelper --version 1.0.7                
#r "nuget: Winform.AutoSizeHelper, 1.0.7"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Winform.AutoSizeHelper as a Cake Addin
#addin nuget:?package=Winform.AutoSizeHelper&version=1.0.7

// Install Winform.AutoSizeHelper as a Cake Tool
#tool nuget:?package=Winform.AutoSizeHelper&version=1.0.7                



A Control Layout Adaptive Resolution Assistant Class for Winform.



  • When the container control changes its size, the controls inside the container are arranged adaptively according to their original layout
  • When dynamically adding a new control within the container, the size,position and font can be adjusted to fit the layout by calling methods
  • If there are nested layouts within the layout, the nested layouts will also be adaptive
  • support autosize the listview(only column width)

How To Use

Basic Use

  1. Design your Form in Form Designer,for example:

  2. Disable the AutoScaleMode property in Form manually. Find Form1.Designer.cs and open it, press Ctrl + F to search string:"AutoScaleMode",then you can see this line:

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

Modify it to System.Windows.Forms.AutoScaleMode.None.

  1. Create a AutoSizeHelper and set the container in Form1's constructor
using AutoSizeTools;
namespace XXX{
  public partial class Form1 : Form{
    AutoSizeHelper helper;
    public Form1()
        helper = new AutoSizeHelper(this);
  1. Run your application,and maximize the application window,then you can see: step3

Dynamically Adding New Controls

if we want to dynamically Add a new button which between button2 and button3 by clicking button6, we can achieve this in the following way:

  1. double click button6 in form deigner,in the following methed,we write code like this:
private void button6_Click(object sender, EventArgs e)
    Button newBtn = new Button();
    newBtn.Name = "button7";
    newBtn.Location = new Point(568, 12);
    newBtn.Size = new System.Drawing.Size(75, 23);
    newBtn.Text = "button7";
    //apply button6's font to newBtn font
    newBtn.Font = new Font(button6.Font.FontFamily, button6.Font.Size);
    newBtn.UseVisualStyleBackColor = true;
  1. Run the application,click button6,you can see button7 showed between button2 and button3. then you can maximize or minimize the application window,the button7 always adapt to the current layout.

Use AutoSizeHelperEx

There are some differences in using AutoSizeHelper and AutoSizeHelperEx. When using AutoSizeHelperEx, it should be noted that you need to call the UpdateControls method in the sizechanged event handler of the form.Such like this(this example is from demo--adjust_font):

private void FontForm_SizeChanged(object sender, EventArgs e)
    Size screenSize = Screen.PrimaryScreen.Bounds.Size;
    if (screenSize == new Size(1920,1080)) 
        helper.FontAdjustRate = 1.0f;
    else if (screenSize == new Size(1280, 960))  
        helper.FontAdjustRate = 0.8f; 
    helper.UpdateControls(); // call this method to refresh UI

The other uses of AutoSizeHelperEx are consistent with AutoSizeHelper.

For more examples, please see github repository.


  • There are some differences between version 1.05 and previous versions(1.0.0~1.0.3). Specifically,I added the AutoSizeHelperEx class in version 1.0.5, which allows you to adjust the font scaling ratio on different resolution screens
  • this tool is suitable for Third party package's Multi page framework(e.g SunnyUI)
Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed. 
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.0

    • No dependencies.
  • .NETFramework 4.7.2

    • No dependencies.
  • net6.0-windows7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.8 362 6/9/2023
1.0.7 230 5/27/2023
1.0.6 138 5/27/2023
1.0.5 140 5/25/2023
1.0.3 134 5/22/2023
1.0.2 118 5/21/2023
1.0.1 139 5/20/2023
1.0.0 126 5/19/2023