How can I hide a TVirtualStringTree node?

北城以北 提交于 2019-12-10 15:14:09

问题


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?


回答1:


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.




回答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();


来源:https://stackoverflow.com/questions/7165405/how-can-i-hide-a-tvirtualstringtree-node

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!