dotnet / dotnet/winforms

Setting SplitContainer.Panel2MinSize incorrectly changes SplitterDistance

Open
#3,568 0 comments 0 reactions 0 assignees View on GitHub
:beetle: bug :construction: work in progress help wanted
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
1d 13m
Merged PRs (30d)
85

Description

* .NET Core Version:
3.1.301

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

**Problem description:**
Changing Panel2MinSize in a horizontally oriented SplitContainer (Panel2 below Panel1) changes the SplitterDistance if Panel2MinSize > Panel2.Width.

**Expected behavior:**
SplitContainer should respect its Orientation when changing Panel2MinSize. Changing Panel2MinSize in a horizontally oriented SplitContainer (Panel2 below Panel1) should only change the SplitterDistance if Panel2MinSize > Panel2.Height.

**Minimal repro:**
```cs
var form = new Form() { Size = new Size(200, 500) };
var splitContainer = new SplitContainer() { Orientation = Orientation.Horizontal };
splitContainer.Dock = DockStyle.Fill;
form.Controls.Add(splitContainer);
form.Show();

Debug.WriteLine(splitContainer.Panel2MinSize); // 25
Debug.WriteLine(splitContainer.Panel2.Height); // 227
Debug.WriteLine(splitContainer.SplitterDistance); // 230

splitContainer.Panel2MinSize = 205;

Debug.WriteLine(splitContainer.Panel2MinSize); // 205
Debug.WriteLine(splitContainer.Panel2.Height); // 269 (should be 227)
Debug.WriteLine(splitContainer.SplitterDistance); // 188 (should be 230)
```

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.