Skip to content

Fix Setting SplitContainer.Panel2MinSize incorrectly changes SplitterDistance#14718

Open
Sathish-087 wants to merge 2 commits into
dotnet:mainfrom
Sathish-087:Fix_Issue_3568
Open

Fix Setting SplitContainer.Panel2MinSize incorrectly changes SplitterDistance#14718
Sathish-087 wants to merge 2 commits into
dotnet:mainfrom
Sathish-087:Fix_Issue_3568

Conversation

@Sathish-087

@Sathish-087 Sathish-087 commented Jul 8, 2026

Copy link
Copy Markdown

Fixes #3568

Proposed changes

  • Fixed SplitContainer.ApplyPanel2MinSize to respect the current Orientation when evaluating the size of Panel2.
  • For vertical orientation, continue using Panel2.Width; for horizontal orientation, use Panel2.Height when enforcing Panel2MinSize.
  • Updated splitter distance calculation to move the splitter only when Panel2 is actually smaller than the required minimum size, preventing unintended splitter repositioning.

Customer Impact

  • Prevents SplitterDistance from being modified unexpectedly when updating Panel2MinSize on a horizontally oriented SplitContainer.
  • Ensures consistent and predictable layout behavior when applications dynamically change Panel2MinSize.

Regression?

  • No

Risk

  • Low. The change is limited to the ApplyPanel2MinSize logic and only affects the condition and calculation used when enforcing the minimum size of Panel2. Existing behavior for vertical orientation remains unchanged while horizontal orientation now uses the correct dimension.

Screenshots

Before

Repro using the code from the reported issue:

Before Panel2MinSize: 25
Before Panel2Height: 223
Before Panel2Width: 182
Before SplitterDistance: 226

splitContainer.Panel2MinSize = 205;

After Panel2MinSize: 205
After Panel2Height: 263
After Panel2Width: 182
After SplitterDistance: 186

SplitterDistance is changed unexpectedly and Panel2.Height is modified even though the requested minimum size is already satisfied.

After

Before Panel2MinSize: 25
Before Panel2Height: 221
Before Panel2Width: 182
Before SplitterDistance: 225

splitContainer.Panel2MinSize = 205;

After Panel2MinSize: 205
After Panel2Height: 221
After Panel2Width: 182
After SplitterDistance: 225

SplitterDistance remains unchanged and the size of Panel2 is preserved.

Test methodology

  • Verified that changing Panel2MinSize on a horizontally oriented SplitContainer no longer changes SplitterDistance when Panel2 already satisfies the requested minimum size.
  • Validated that the existing behavior for vertical orientation remains unchanged and that minimum size enforcement continues to work correctly when Panel2 is smaller than the requested value.

Accessibility testing

  • NA

Test environment(s)

  • Windows 11
  • .NET SDK: 11.0.100-preview.3.26170.106
Microsoft Reviewers: Open in CodeFlow

@Sathish-087 Sathish-087 requested a review from a team as a code owner July 8, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting SplitContainer.Panel2MinSize incorrectly changes SplitterDistance

1 participant