Skip to content

Fix issue 15345: TreeView OwnerDrawText Flickering even in TVS_EX_DOUBLEBUFFER - #15406

Merged
SimonZhao888 merged 2 commits into
dotnet:mainfrom
SimonZhao888:Fix_Issue_15345
Nov 13, 2026
Merged

SimonZhao888 merged 2 commits into
dotnet:mainfrom
SimonZhao888:Fix_Issue_15345

Conversation

@SimonZhao888

@SimonZhao888 SimonZhao888 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Fixes #15345

Root Cause

In OwnerDrawText mode, TreeView always requested CDRF_NOTIFYPOSTPAINT, even when the native custom-draw notification contained an empty paint rectangle. With TVS_EX_DOUBLEBUFFER, this caused unnecessary post-paint drawing and visible flickering.

Proposed changes

Only request post-paint notifications when the custom-draw rectangle has a valid, non-empty paint area. Empty paint regions now return CDRF_NEWFONT without requesting post-paint processing.

Customer Impact

Eliminates flickering for owner-drawn TreeView text when double buffering is enabled, while preserving existing rendering behavior for valid paint regions.

Regression?

  • No

Risk

  • Mini

Screenshots

Before

Before.mp4

After

After.mp4

Test methodology

  • Manual

Test environment(s)

  • 11.0.100-rc.2.26509.113

Test demo

TreeView15345Repro.zip

Microsoft Reviewers: Open in CodeFlow

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 new custom-draw branch lacks a focused regression test verifying that empty or inverted rectangles omit CDRF_NOTIFYPOSTPAINT while non-empty rectangles retain it.

1 open issue
What changed in this PR

Addresses #15345 by preventing unnecessary post-paint drawing in TreeView’s OwnerDrawText mode, targeting flicker when native double buffering is enabled.

Changes:

  • Requests post-paint notifications only when the custom-draw rectangle has positive width and height.
  • Preserves CDRF_NEWFONT for all rectangles and existing post-paint behavior for valid paint areas.
File Description
src/​System.Windows.Forms/​System/​Windows/​Forms/​Controls/​TreeView/​TreeView.cs Guards owner-drawn text post-paint requests with a positive-area rectangle check.

Review effort: Balanced

@codecov

codecov Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.79260%. Comparing base (8d62c3c) to head (464f3c5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@              Coverage Diff              @@
##                main      #15406   +/-   ##
=============================================
  Coverage   39.79260%   39.79260%           
=============================================
  Files            246         246           
  Lines           9836        9836           
  Branches        1036        1036           
=============================================
  Hits            3914        3914           
  Misses          5741        5741           
  Partials         181         181           
Flag Coverage Δ
Debug 39.79260% <ø> (ø)
production 42.31695% <ø> (ø)
test 19.92786% <ø> (ø)
unit 42.31695% <ø> (ø)

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.

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.

🟢 Approval recommended

No active review issues block the change to avoid unnecessary TreeView post-paint drawing.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@SimonZhao888
SimonZhao888 merged commit 5588335 into dotnet:main Nov 13, 2026
8 checks passed
@SimonZhao888
SimonZhao888 deleted the Fix_Issue_15345 branch November 13, 2026 02:49
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 14, 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.

TreeView OwnerDrawText Flickering even in TVS_EX_DOUBLEBUFFER

4 participants