dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.4k stars 980 forks source link

Control location changes in the NetFrameFramework #4549

Open sampathnarine opened 3 years ago

sampathnarine commented 3 years ago

3.1project

Yes

Problem description:

I have created the Netcore 3.1 project and i have added the datagridview and button in the designer level. Then I have added the button in the constructor of the form and set some location. Please find the code snippet below.

public Form1()
{
    InitializeComponent();
    Button button = new Button() { Size = new System.Drawing.Size(200, 50), Text = "Click" };
    Panel panel = new Panel();
    panel.Controls.Add(button);
    this.Controls.Add(panel);
    panel.Location = new System.Drawing.Point(1389, 150);
    OrderInfoCollection data = new OrderInfoCollection();
    dataGrid.DataSource = data.OrdersListDetails;
}

While i open the same application in the netframework, the button location changes. Please refer the below screenshots.

NetCore

NetCore_alignmentIssue

NetFrameWork

image

Expected behavior:

I dont know why the location changes in the Netframework and this location changes should not occur.

Minimal repro:

Run the NetCore project and 2017 project of below attached sample.

Sample.zip

sampathnarine commented 3 years ago

Hi Guys,

Can i get any update on this?

AraHaan commented 3 years ago

I think it was due to behaviour changes I get the same bug when trying to create bounding boxes to draw my own form's window itself.

It is an odd bug that I for 1 need to investigate between net472, and even in net5.0.

Oddly enough on most of my forms it's ok until I get to my settings form then it goes 🔥.

merriemcgaw commented 3 years ago

We will need to investigate this a little more deeply. We haven't come to a conclusion just yet.

JeremyKuhne commented 1 year ago

@dreddy-work can you please take a look to determine what to do with this issue?

elachlan commented 12 months ago

@Olina-Zhang could your team please test this to see if its still an issue?

Eudora-Li01 commented 12 months ago

Verified this issue with Sample.zip that provided by user on .NET3.1 & .NET9 & .NET Framework 4.8.1, whose result are same. The position of click button is not aligned with load button. Details as below:

https://github.com/dotnet/winforms/assets/130345015/8dac80e0-3e18-4aca-8e2f-98918f3de258