dotnet / dotnet/winforms

Controls with bottom anchor can inexplicably shrink in PerMonitor/V2 even with AutoScaleMode.None

Open
#10,490 6 comments 0 reactions 0 assignees View on GitHub
:beetle: bug area-HDPI-PMv2
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
20h 23m
Merged PRs (30d)
103

Description

### .NET version

Issue is the same on both .NET 6.0 and 8.0.

### Did it work in .NET Framework?

Not tested/verified

### Did it work in any of the earlier releases of .NET Core or .NET 5+?

_No response_

### Issue description

When the bottom edge of the label gets near the padding of the bottom edge of the containing form, the label gets inexplicably resized at runtime.

Designer:
![image](https://github.com/dotnet/winforms/assets/8040367/6e479e02-3810-4363-b192-b1f2684145e1)

Running the app:
![image](https://github.com/dotnet/winforms/assets/8040367/fcadb2b1-f57f-4923-b270-9d0f57598efb)

### Steps to reproduce

[Repro.zip](https://github.com/dotnet/winforms/files/13694666/Repro.zip)

InitializeComponent contents from the full attached repro:

```cs
label1 = new System.Windows.Forms.Label();
SuspendLayout();
//
// label1
//
label1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
label1.BackColor = System.Drawing.Color.Fuchsia;
label1.Location = new System.Drawing.Point(3, 87);
label1.Name = "label1";
label1.Size = new System.Drawing.Size(380, 24);
label1.TabIndex = 1;
label1.Text = "Distance to the bottom of the form is important";
label1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
//
// MainForm
//
AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
ClientSize = new System.Drawing.Size(386, 126);
Controls.Add(label1);
Name = "MainForm";
Padding = new System.Windows.Forms.Padding(0, 0, 0, 16);
Text = "Windows Forms repro";
ResumeLayout(false);

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.