Repository navigation
Fix issue 15345: TreeView OwnerDrawText Flickering even in TVS_EX_DOUBLEBUFFER - #15406
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 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_NEWFONTfor 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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
SimonZhao888
requested review from
KlausLoeffelmann,
LeafShi1,
Shyam-Gupta and
ricardobossan
November 12, 2026 01:57
Shyam-Gupta
approved these changes
Nov 12, 2026
LeafShi1
approved these changes
Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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?
Risk
Screenshots
Before
Before.mp4
After
After.mp4
Test methodology
Test environment(s)
Test demo
TreeView15345Repro.zip
Microsoft Reviewers: Open in CodeFlow