Refreshing a TTreeView

I'm hoping someone has seen this problem.

I have a TTreeView component with lots of stuff.

I have a procedure that steps through the entire Tree and changes the ImageIndex to certain values depending on certain criteria.

I've noticed that if part of the Tree is not visible when this icon change takes place, the icons will not change properly for the portion of the Tree that is not visible, meaning, when I scroll that part of the Tree into view, the icons have not changed.

Hope someone can help.

Sorry for the low points.  I only have 9 points left now.
LVL 5
Tom KnowltonWeb developerAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
LischkeConnect With a Mentor Commented:
You found it yourself. I just earn the points for listening ;-))

Ciao, Mike
0
 
Tom KnowltonWeb developerAuthor Commented:
Edited text of question.
0
 
Tom KnowltonWeb developerAuthor Commented:
Edited text of question.
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Tom KnowltonWeb developerAuthor Commented:
Edited text of question.
0
 
LischkeCommented:
This is a very strange behaviour (and I have seen a lot of strange things with the treeview). Wasn't there a method RepaintNode or something like that? Try this or (just to see it works) TTreeView.Refresh.

Ciao, Mike
0
 
Tom KnowltonWeb developerAuthor Commented:
TTreeView.Refresh only repaints the portion of the Tree you can SEE in the TreeView window.  I think.

btw- this is the normal TreeView, not TreeNT that is displaying this behavior.
0
 
Tom KnowltonWeb developerAuthor Commented:
I think I found what was wrong.

I've been using TreeView1.TopItem before traversing the tree.  I thought that TopItem when to the VERY first node in the tree.  

This is not the case, it seems.

It looks like TopItem goes to the very top VISIBLE node in the Tree.  So, if you're at the bottom of the Tree, it's the first node you see at the top of the TreeView window, not the very first level 0 item in the entire TreeView.
0
 
Tom KnowltonWeb developerAuthor Commented:
Yep, that was it.

I needed to use TreeView1.Items.GetFirstNode.

Now the Tree refreshes correctly.

Mike, repost this as an answer and I'll give you the points.  I want to keep this question and answer for future reference.

Tom
0
 
Tom KnowltonWeb developerAuthor Commented:
Correct.  :)
0
All Courses

From novice to tech pro — start learning today.