Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / April 2005

Tip: Looking for answers? Try searching our database.

Treeview Flickering

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tomas Deman - 10 May 2004 15:20 GMT
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
AlexS - 10 May 2004 18:23 GMT
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

> Hi,
>
[quoted text clipped - 12 lines]
> Thanks for helping me out!
> Tomas
Tomas Deman - 10 May 2004 15:45 GMT
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. :(

> I would suggest to modify properties in steps. And would start from
> AllPainting and DoubleBuffer only.
[quoted text clipped - 21 lines]
> > Thanks for helping me out!
> > Tomas
AlexS - 10 May 2004 18:56 GMT
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 tried to modify the properties in steps, and saw it was
> ControlStyles.Userpaint that causes the trouble.
[quoted text clipped - 28 lines]
> > > Thanks for helping me out!
> > > Tomas
Tomas Deman - 10 May 2004 16:04 GMT
Hmm,
I only update one node (2 at max) Text property at a time.
It's weird all the other nodes are flickering too.

> Tomas,
>
[quoted text clipped - 44 lines]
> > > > Thanks for helping me out!
> > > > Tomas
chris m - 10 Jun 2004 05:11 GMT
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);
}

> Hmm,
> I only update one node (2 at max) Text property at a time.
[quoted text clipped - 49 lines]
> > > > > Thanks for helping me out!
> > > > > Tomas
Chris Murphy - 14 Apr 2005 16:21 GMT
Use the BeginUpdate() and EndUpdate() methods to encapsulate the code
you're using to update the text in the node. I've just used that solution
recently while developing an inherited Treeview Control.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.