treeview ExpandTopLevelNodes method
Return to Introduction  Previous page  Next page
Applies to
acTreeView component (and acTreeComboBox as subproperty of TreeOptions structure).  

Declaration
procedure ExpandTopLevelNodes;  

Description
The ExpandTopLevelNodes method expands all the top-level nodes in the tree-view. The "top-level" nodes is the nodes where the Parent property is nil (no upper node).  

Original code
procedure TacTreeView.ExpandTopLevelNodes;  
var  
  I: Integer;  
begin  
  I := Items.Count;  
  if I <> 0 then  
   begin  
    Items.BeginUpdate;  
    try  
      for I := 0 to I - 1 do  
       if Items[I].Parent = nil then  
        Items[I].Expand(False);  
    finally  
      Items.EndUpdate;  
    end;  
   end;  
end;  

See also
TreeOptions property of acTreeComboBox component.