TreeView flickering
See original GitHub issue-
.NET Core Version: all up to latest (5.0.5).
-
Have you experienced this same bug with .NET Framework?: yes
Problem description:
TreeView is flickering (especially on large amount of data):
Native control has ex. style TVS_EX_DOUBLEBUFFER
that fix the problem:
private class TreeViewEx : TreeView
{
private const int TVM_SETEXTENDEDSTYLE = 0x1100 + 44;
private const int TVS_EX_DOUBLEBUFFER = 0x0004;
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
private static extern IntPtr SendMessage(IntPtr HWnd, int Msg, IntPtr Wp, IntPtr Lp);
protected override void OnHandleCreated(EventArgs e)
{
SendMessage(this.Handle, TVM_SETEXTENDEDSTYLE, (IntPtr)TVS_EX_DOUBLEBUFFER, (IntPtr)TVS_EX_DOUBLEBUFFER);
base.OnHandleCreated(e);
}
}
Left default TreeView
, Right with TVS_EX_DOUBLEBUFFER
:
stackoverflow.
Expected behavior:
Ability to avoid flickering without Pinvoke and deriving own class from TreeView
.
P.s. protected DoubleBuffered
doesn’t solve the problem.
P.p.s. May be API request is more suitable here?
Minimal repro: TreeViewFlickering.zip
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:16 (14 by maintainers)
Top Results From Across the Web
c# - Treeview flickering?
Getting flicker at EndUpdate() is inevitable, it repaints the control. They were designed to speed-up adding a bulk of nodes, that will be...
Read more >TreeView.DoubleBuffered Property (System.Windows.Forms)
Setting the DoubleBuffered property does not affect the TreeView control. If you want to reduce flicker when the TreeView is drawn, use the...
Read more >Re: TreeView Flickering Problem
TreeView Flickering Problem. Anyone know how I can get rid of the annoying flickering that happens when my code updates the nodes.
Read more >Prevent flickering when updating TreeView nodes
I'm working on an RSS reader in .NET 2.0. It's a WinForms app. Like most RSS readers, it's got an outlook-style layout with...
Read more >TreeView flickering? - C# Discussion Boards
So, I've essentially implemented a folder browser with a TreeView, and what I'm doing is trying to get it to remove flickering. Here's...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
A proposal it is.
According to the docs
DoubleBuffered=true
makes no difference, though this would be the first thing I’d try. Perhaps this is something we could consider enhancing. @merriemcgaw @KlausLoeffelmann what do you think?Also interestingly enough we have this method: https://github.com/dotnet/winforms/blob/d46ad2e8dc76248739d9ae22b28b399a6a6b299e/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/DesignerUtils.cs#L878-L892