What is the best Delphi algorithm to display a tree view for displaying an existing hierarchy of objects

StackOverflow https://stackoverflow.com/questions/5929620

Pergunta

This sounds really simple but it's like an onion - lots of layers as you peel. I have a hierarchy of my own object classes - a bit like the components on a form really, in that any of them can have children and a parent. At the top there is a root object. Other code manages this hierarchy and it is possible that branches or leaves may be created, deleted or renamed at any time. I wish to have a tree view (of some kind, probably virtual) which provides a view of this hierarchy in such a way that it is possible to have multiple of these tree views, each drawing themselves from the object hierarchy as required.

I already have a solution using Delphi's TTreeView but it relies on iterating through the hierarchy when a 'changed' flag is raised and rebuilding tree view branches that have changed. This is slow (I can have over 1000 objects) and I'd like an algorithm that manages to do a single tree view change for a single object insertion or deletion.

Is this possible?

Nenhuma solução correta

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top