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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tom KnowltonWeb developerAuthor Commented:
Edited text of question.
0
Tom KnowltonWeb developerAuthor Commented:
Edited text of question.
0
Tom KnowltonWeb developerAuthor Commented:
Edited text of question.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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
LischkeCommented:
You found it yourself. I just earn the points for listening ;-))

Ciao, Mike
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tom KnowltonWeb developerAuthor Commented:
Correct.  :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.