Beta Documentation - Subject to change.

A control to display data in a tree.

Remarks

This control display a hierarchy of nodes that can be expanded and collapsed. This base control does not automatically expand or collapse nodes. It is the responsibility of the scripter to invoke the SetExpanded method on the nodes in response to user input.

Examples

This example demonstrates creating a tree view control and populating it with nodes.
Using a TreeViewCopy Code
   
    -- Define a tree node class to put into the tree.
    MyTreeNode = class( Turbine.UI.TreeNode );
    
    function MyTreeNode:Constructor()
    	Turbine.UI.TreeNode.Constructor( self );
    	
    	self:SetBackColor( Turbine.UI.Color( math.random(), math.random(), math.random() ) );
    	self:SetSize( 100, 18 );
    end
    
    -- Create the container window.
    window = Turbine.UI.Lotro.Window();
    window:SetSize( 400, 400 );
    window:SetPosition( 100, 100 );
    window:SetText( "Treeview test" );
    window:SetVisible( true );
    
    -- Create the tree view control.
    treeView = Turbine.UI.TreeView();
    treeView:SetParent( window );
    treeView:SetPosition( 10, 50 );
    treeView:SetSize( 300, 200 );
    treeView:SetBackColor( Turbine.UI.Color( 0.2, 0.2, 0.2 ) );
    treeView:SetIndentationWidth( 15 );
    
    -- Give the tree view a scroll bar.
    scriptTextScrollBar = Turbine.UI.Lotro.ScrollBar();
    scriptTextScrollBar:SetOrientation( Turbine.UI.Orientation.Vertical );
    scriptTextScrollBar:SetParent( window );
    scriptTextScrollBar:SetPosition( 300, 50 );
    scriptTextScrollBar:SetSize( 10, 200 );
    
    treeView:SetVerticalScrollBar( scriptTextScrollBar );
    
    -- Populate the test nodes.
    rootNodes = treeView:GetNodes();
    
    local i;
    local j;
    
    for i = 1, 5 do
    	local node = MyTreeNode();
    	rootNodes:Add( node );
    
    	local subNodes = node:GetChildNodes();
    
    	for j = 1, 5 do
    		local node = MyTreeNode();
    		subNodes:Add( node );
    
    		local subNodes = node:GetChildNodes();
    
    		for k = 1, 5 do
    			local node = MyTreeNode();
    			subNodes:Add( node );
    
    			local subNodes = node:GetChildNodes();
    
    			for l = 1, 5 do
    				local node = MyTreeNode();
    				subNodes:Add( node );
    /// 			end
    		end
    	end
    end

Inheritance Hierarchy

Turbine.Object
  Turbine.UI.Control
    Turbine.UI.ScrollableControl
      Turbine.UI.TreeView

See Also