dotnet / dotnet/winforms

Control location changes in the NetFrameFramework

Open
#4,549 6 comments 0 reactions 0 assignees View on GitHub
:beetle: bug area-Layout tenet-compatibility
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
1d 13m
Merged PRs (30d)
85

Description

* .NET Core Version:

3.1project

* Have you experienced this same bug with .NET Framework?:

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](https://user-images.githubusercontent.com/63052528/107455759-52d57a80-6b75-11eb-82cd-2c0eb4e898cf.png)

**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](https://github.com/dotnet/winforms/files/5955508/Sample.zip)

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.