5
votes

if I'm not mistaken it's not possible to have invisible nodes in a TVirtualStringTree treeview, as there are no enabled, visible or other properties to do so. Am I right about this?

If yes, how did I manage to have a non visible node?

Structure of my tree:

  • One Node
  • Another node
    • Subnode 1
    • Subnode 2
    • ...
    • Subnode 15
    • Subnode 16 (which is not visible!)
  • Yet another node
    • Subnode 1 from yet another node
    • Subnode 2 from yet another node

I can find Subnode 16 when I do a FirstNode/GetNextNode loop over the whole tree and let me print out the text for the first column. I can also inspect the node and see that he's got a previous sibling but no next sibling for instance and the node height is 18.

So how did I do this?

2
Welcome to Stack Overflow. In its current state, this question requires us guessing, from which neither of us will benefit. Please provide a sample of the code wherein you populate the tree, along with your verification code which generates the above text. - NGLN
Is this some kind of game show where we have to guess your code and the best guess wins a speed boat? - David Heffernan

2 Answers

22
votes

if I'm not mistaken it's not possible to have invisible nodes in a TVirtualStringTree treeview, as there are no enabled, visible or other properties to do so. Am I right about this?

You are wrong, it is possible to have both invisible and disabled nodes. To switch visible state of the node use

vtree.IsVisible[Node] := boolean;

to enable / disable node use

vtree.IsDisabled[Node] := boolean;

You can also initialize node to disabled state in tree's OnInitNode event with adding ivsDisabled to InitialStates parameter.

1
votes

In Addition to ains answer, to recurse the tree you can use the following functions:

To recurse ALL nodes

Tree.GetFirst();
Tree.GetNext();
Tree.GetPrevious();

To recurse only VISIBLE nodes:

Tree.GetFirstVisible();
Tree.GetNextVisible();
Tree.GetPreviousVisible();