You are right that this is very slow and the documentation also stated this
TTreeView.Items
http://docwiki.embarcadero.com/Libraries/XE6/en/Vcl.ComCtrls.TTreeView.Items
Note: Accessing tree view items by index can be time-intensive, particularly when the tree view contains many items. For optimal performance, try to design your application so that it has as few dependencies on the tree view's item index as possible.
But there are some methods to walk through the tree:
Get the very first node by calling
MyNode := MyTreeView.Items[0];
.
Walk through the tree until you get the desired level with
TTreeNode.Next
Delphi-Quellcode:
while Assigned( MyNode ) and ( MyNode.Level <> ALevel ) do
MyNode := MyNode.GetNext;
Once you got the node at the desired level you can step through all nodes on this level with
TTreeNode.GetNextSibling
Delphi-Quellcode:
while Assigned( MyNode ) do
MyNode := MyNode.GetNextSibling;
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ea 0a 4c 14 0d b6 3a a4 c1 c5 b9
dc 90 9d f0 e9 de 13 da 60)