dotnet / dotnet/winforms

Incorrect toolbar location at 125%+ scale factor

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

Description

Presumably all versions:
* .NET Framework: 4.6.1 (tested)
* .NET Version: 5.0 (tested)

**Problem description:**

Originally reported in https://github.com/gitextensions/gitextensions/issues/8680.

An application with two toolbars placed on the same lane, one after another. When the app is run in scaled environments (i.e. 125%+) the toolbars will get re-odered if the first toolbar becomes longer than the location of the second toolbar.

The same problem isn't observed at 100% scale factor, or if the repro app doesn't use its app.manifest.

* Designer:
![image](https://user-images.githubusercontent.com/4403806/104089377-9ca31a80-52c2-11eb-8884-148fb2b63fc9.png)

* Runtime 100%
![image](https://user-images.githubusercontent.com/4403806/104089397-c4927e00-52c2-11eb-9b42-fede30dde77f.png)

* Runtime 150%
![image](https://user-images.githubusercontent.com/4403806/104089413-decc5c00-52c2-11eb-932f-79236d5306ad.png)

**Expected behavior:**

The order of the toolbars set at the design time must be preserved.

A workaround is to remove all toolbars after `InitializeComponent();` and add them back in the correct order, e.g.:
```cs
public FormBrowse()
{
InitializeComponent();

this.toolPanel.TopToolStripPanel.Controls.Clear();
this.toolPanel.TopToolStripPanel.Controls.Add(this.ToolStripFilters);
this.toolPanel.TopToolStripPanel.Controls.Add(this.ToolStripMain);

}
```

**Minimal repro:**

1. clone https://github.com/RussKie/Test-ToolStripOrder
2. run the app at 100% - observe `ToolStripMain` before `ToolStripFilters`
3. run the app at 150%+ - observe the reverse order of toolbars

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.