6

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?

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
Markus
  • 69
  • 1
  • 2
  • 3
    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 Aug 23 '11 at 18:10
  • 5
    Is this some kind of game show where we have to guess your code and the best guess wins a speed boat? – David Heffernan Aug 23 '11 at 18:45

2 Answers2

23

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.

ain
  • 22,394
  • 3
  • 54
  • 74
  • +1 for using `.IsVisible[]`, which adjusts the overall height of the tree view's canvas so the vertical scroll bar will reflect the hidden node(s). If you simply remove the visible state from the node using `Exclude(Node.States, vsVisible)` or `Node.States := Node.States - vsVisible`, it will not adjust the tree view's canvas height, the vertical scroll bar will not change, and the user will potentially have a lot of white-space beneath the last displayed node. – James L. Oct 29 '13 at 22:19
2

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();
Simon
  • 9,197
  • 13
  • 72
  • 115