Skip to main content
TeeTree provides multiple flexible methods to create tree structures and add nodes. This guide covers the essential techniques for building your tree hierarchies.

Understanding Tree Structure

A TeeTree component maintains a network-hierarchy of nodes, where:
  • Root nodes have no parent
  • Child nodes belong to a parent node
  • Brother nodes share the same parent
  • Each node is a full component with properties, methods, and events

Adding Root Nodes

Root nodes are the top-level nodes in your tree without any parent.
The Add method without a parent parameter automatically creates a root node.

Adding Child Nodes

Child nodes are attached to a parent node and form the tree hierarchy.
1

Using Parent Node

The most direct way is to call AddChild on the parent node:
2

Using Tree Component

Pass the parent as the second parameter:
3

Using Shapes Collection

Use the Shapes collection’s AddChild method:

Child Node Variations

Adding Brother Nodes

Brother nodes (siblings) share the same parent as an existing node.
Before calling AddBrother, check if the node has a parent. Root nodes have no parent, so you should create a new root instead.

10 Methods to Add Nodes

Here’s a comprehensive example from the TeeTree demo showing different addition techniques:

Expanding Nodes

After creating child nodes, expand the parent to make them visible:

Interactive Node Addition

Example of adding nodes interactively based on user selection:

Inserting Nodes at Specific Positions

Best Practices

When adding many nodes, set capacity for better performance:
  • Nodes are automatically freed when their parent is destroyed
  • Root nodes are freed when the Tree component is destroyed
  • Use Clear to remove all nodes: Tree1.Shapes.Clear
  • Group related nodes under common parents
  • Use meaningful text for node identification
  • Consider using Data or TagObject properties to associate custom data

Common Patterns

Building from Data

Building Hierarchical Structure

Next Steps