Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I make a TTreeNode invisible?

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.

like image 555
dummzeuch Avatar asked May 06 '09 05:05

dummzeuch


2 Answers

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.

like image 121
Argalatyr Avatar answered Oct 30 '22 12:10

Argalatyr


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

like image 27
Tool Avatar answered Oct 30 '22 13:10

Tool