Skip to content

Fix issue 15031: Disable NET11 VisualStylesMode for composite controls (ToolStrip, DataGridView, etc.) until NET11 layout modernization is completed - #15033

Open
SimonZhao888 wants to merge 2 commits into
dotnet:mainfrom
SimonZhao888:Fix_Issue_15031
Open

Fix issue 15031: Disable NET11 VisualStylesMode for composite controls (ToolStrip, DataGridView, etc.) until NET11 layout modernization is completed#15033
SimonZhao888 wants to merge 2 commits into
dotnet:mainfrom
SimonZhao888:Fix_Issue_15031

Conversation

@SimonZhao888

@SimonZhao888 SimonZhao888 commented Sep 3, 2026

Copy link
Copy Markdown
Member

Fixes #15031

Proposed changes

  • Disable NET11 VisualStylesMode for composite controls (ToolStrip, DataGridView, etc.) until NET11 layout modernization is completed

Customer Impact

  • Controls such as ToolStrip and DataGridView are displayed in Classic mode and cannot currently display Net11 style effects.

Regression?

  • No

Risk

  • Mini

Screenshots

Before

image

After

image

Test methodology

  • Manually
  • Automated test cases

Accessibility testing

Test environment(s)

  • 11.0.0-preview.7.26381.103
Microsoft Reviewers: Open in CodeFlow

…s (ToolStrip, DataGridView, etc.) until NET11 layout modernization is completed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The current OnParentVisualStylesModeChanged early-return path can suppress propagation/notifications when removing a local VisualStylesMode value changes the effective mode under coercion.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Disables modern VisualStylesMode rendering for composite controls (currently ToolStrip and DataGridView) by coercing Net11/Latest requests to Classic, and adds unit tests to lock in the expected effective-mode behavior and eventing.

Changes:

  • Add per-control coercion hook (GetSupportedVisualStylesMode) and override it in ToolStrip/DataGridView to force Classic for Net11 and newer modes.
  • Adjust Control visual-styles inheritance / transition plumbing to account for coercion when determining effective-mode changes.
  • Add unit tests validating ToolStrip/DataGridView effective mode is Classic under modern requests and that parent modern-mode transitions do not raise VisualStylesModeChanged when effective mode is unchanged.
File summaries
File Description
src/System.Windows.Forms/System/Windows/Forms/Control.cs Adds supported-mode coercion hook and updates inheritance/transition logic to respect coerced effective modes.
src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/ToolStrip.cs Forces Net11/Latest requests to use Classic effective visual styles mode.
src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridView.cs Forces Net11/Latest requests to use Classic effective visual styles mode.
src/test/unit/System.Windows.Forms/System/Windows/Forms/ToolStripTests.cs Adds tests ensuring modern requests result in Classic effective mode and no spurious change events.
src/test/unit/System.Windows.Forms/System/Windows/Forms/DataGridViewTests.cs Adds tests ensuring modern requests result in Classic effective mode and no spurious change events.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/System.Windows.Forms/System/Windows/Forms/Control.cs
@SimonZhao888 SimonZhao888 added the waiting-review This item is waiting on review by one or more members of team label Sep 3, 2026
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.24166%. Comparing base (1dfc02d) to head (ff2ec3f).
⚠️ Report is 197 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (1dfc02d) and HEAD (ff2ec3f). Click for more details.

HEAD has 3 uploads less than BASE
Flag BASE (1dfc02d) HEAD (ff2ec3f)
Debug 3 2
production 2 1
integration 1 0
Additional details and impacted files
@@                 Coverage Diff                  @@
##                main      #15033          +/-   ##
====================================================
- Coverage   77.31435%   37.24166%   -40.07269%     
====================================================
  Files           3265         246        -3019     
  Lines         644447        9774      -634673     
  Branches       47631        1029       -46602     
====================================================
- Hits          498250        3640      -494610     
+ Misses        142509        5970      -136539     
+ Partials        3688         164        -3524     
Flag Coverage Δ
Debug 37.24166% <ø> (-40.07270%) ⬇️
integration ?
production 39.36526% <ø> (-12.91627%) ⬇️
test 20.64923% <ø> (-76.76994%) ⬇️
unit 39.36526% <ø> (-10.26895%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@KlausLoeffelmann

Copy link
Copy Markdown
Member

@LeafShi1, @SimonZhao888, @ricardobossan ... and also everybody else - just asking:

Should we quirk that with an AppContext switch?
(And I am NOT saying we should. But I am also not saying we should not.)

@KlausLoeffelmann KlausLoeffelmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!!
Can't wait to see this live!!

Thanks a lot!

@KlausLoeffelmann KlausLoeffelmann removed the waiting-review This item is waiting on review by one or more members of team label Sep 4, 2026
@SimonZhao888

Copy link
Copy Markdown
Member Author

Yes!! Can't wait to see this live!!

Thanks a lot!

Did you misread that PR draft? It likely still needs further revision.

@SimonZhao888 SimonZhao888 added the draft draft PR label Sep 4, 2026
@dotnet-policy-service dotnet-policy-service Bot removed the draft draft PR label Sep 4, 2026
@SimonZhao888 SimonZhao888 added the draft draft PR label Sep 4, 2026
@dotnet-policy-service dotnet-policy-service Bot removed the draft draft PR label Sep 4, 2026
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.

Disable NET11 VisualStylesMode for composite controls (ToolStrip, DataGridView, etc.) until NET11 layout modernization is completed

3 participants