Miguel Oz
asked on
How to expand all nodes in a virtual tree (TVirtualStringTree)
I have a virtual tree with the following information:
- My node sample
- Folder 1
- File 1
- File 2
- Folder 2
- File 2.1
I have already defined OnInitNode and OnInitChildren so that the contents are rendered OK from my folder container.
If at startup I run this method
procedure TWndDynamicHierarchy.Initi aliseHiera rchyTreeVi ew;
begin
VstHierarchy.RootNodeCount := 1;
VstHierarchy.Expanded[VstH ierarchy.R ootNode] := TRUE;
end;
My form is showing me only one node not expanded.
+ My node sample
instead of the whole expanded tree.
How can my code expand all nodes after running InitialiseHierarchyTreeVie w (This is running within a begin/end update)
Note: I need the nodes expanded only the first time. InitialiseHierarchyTreeVie w is run only once before a form is shown.
- My node sample
- Folder 1
- File 1
- File 2
- Folder 2
- File 2.1
I have already defined OnInitNode and OnInitChildren so that the contents are rendered OK from my folder container.
If at startup I run this method
procedure TWndDynamicHierarchy.Initi
begin
VstHierarchy.RootNodeCount
VstHierarchy.Expanded[VstH
end;
My form is showing me only one node not expanded.
+ My node sample
instead of the whole expanded tree.
How can my code expand all nodes after running InitialiseHierarchyTreeVie
Note: I need the nodes expanded only the first time. InitialiseHierarchyTreeVie
in TTreeView, there is a simplest way to do that :
TreeView.FullExpand;
(and TreeView.FullCollapse for the opposite)
TreeView.FullExpand;
(and TreeView.FullCollapse for the opposite)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It works. Call it after EndUpdate
Expand
procedure TForm1.Button1Click(Sender
var i : integer;
begin
for I := 0 to TreeView1.Items.Count - 1 do
begin
TreeView1.Items[I].Expand(
end;
end;
collapse
procedure TForm1.Button2Click(Sender
var i : integer;
begin
for I := 0 to TreeView1.Items.Count - 1 do
begin
TreeView1.Items[I].Collaps
end;
end;