Treeview Flickering

  • Thread starter Thread starter Tomas Deman
  • Start date Start date
T

Tomas Deman

Hi,

My treeview is flickering whenever I change the text property of a node.
I was searching the newsgroups on how to resolve this problem, and found the
following solution:
Inherited from a treeview and added the following code to its constructor:
this.SetStyle(ControlStyles.UserPaint
| ControlStyles.AllPaintingInWmPaint
| ControlStyles.DoubleBuffer
| ControlStyles.ResizeRedraw, true );

However, when I try this nothing at all is drawn! What am i missing?
I am using C#.NET with VS2003

Thanks for helping me out!
Tomas
 
I tried to modify the properties in steps, and saw it was
ControlStyles.Userpaint that causes the trouble.
However, when I remove this, the treeview still has the annoying flickering,
so this doesn't solve my problem.
Adding Begin/Endupdate doesn't change anything either. :(
 
Hmm,
I only update one node (2 at max) Text property at a time.
It's weird all the other nodes are flickering too.
 
I would suggest to modify properties in steps. And would start from
AllPainting and DoubleBuffer only.
Another thing is - you can try to use treeview.BeginUpdate/EndUpdate calls
around your updating code, which will prevent internal redraws.

HTH
Alex
 
Tomas,

treeview will flicker always on every update. It's I think by design. If
some node is changed treeview has to go through all visible part of the tree
at least to redraw properly. If you update only one node - I don't know if
somebody (except maybe MS?) will help you. However, if you update several
nodes - Begin/EndUpdate definitely will reduce multiple flickers to single
one.

HTH
Alex
 
i had a similar problem and how i solved that (partially) is by
preventing the control from erasing its background. this is the code
to do it

protected override void WndProc(ref Message messg)
// turn the erase background message into a null message
if ((int)0x0014 == messg.Msg) //if message is is erase background
{
messg.Msg = (int) 0x0000; //reset message to null
}
base.WndProc(messg);
}
 
Back
Top