TTreeNode does not have a Visible property, so the obvious option does not exist. Is there any other way to make a TTreeNode and all its child nodes invisible? Of course I want to be able to make it visible again later.
This is with Delphi 2007.
Note#1: I am aware of the alternative TVirtualTreeView, and I will check it out if there is no easy way to accomplish this with TTreeView.
Note#2: I need the option only for top level nodes. The ones I want to hide usually don't even have children.
It's a good idea to separate data from the user interface, and this issue with tree views is a good example - don't store data in a tree view. I often have a non-visual unit that contains a structured class that stores data. A user interface unit can have a treeview that can displays (a configurable subset of) data from that class. There are a variety of ways to move data between the two. This type of isolation requires a bit of planning, but provides much greater flexibility and stability.
if you want to use a better tree component, why not use Virtualtreeview. It is one of the best components ever developed for Delphi and it's free to use with source! But there is maybe a logical problem with hiding a ttreenode! Should the tree show a + sign when no nodes are visible?
http://wiki.lazarus.freepascal.org/VirtualTreeview
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With