Show TTreeViewItem's Expander button

505 views Asked by At

I have a FireMonkey application that shows list of items in a TTreeView. Some items represent leaf objects, others represent containers. My idea is not to pre-load the whole tree at once. I want to add the sub items to containers only after the user clicks on a particular container item.

For this to happen I need to show the user that the corresponding item is a container:

enter image description here

Is there any way to show the expander of a particular TTreeViewItem without adding any subitems using styles, RTTI etc.?

I'm using Delphi XE7.

1

There are 1 answers

0
Jerry Dodge On BEST ANSWER

There's a common trick using a "dummy" node within each unexpanded node. Each node which has items will have just an empty child node. When the user expands that node, check for this dummy node. If it's there, delete it, and then fill in the real items. I'm not exactly sure how similar the tree view is in Firemonkey and VCL, but the concept should work the same.