Mark- 29 Posted January 30, 2022 Hello, Delphi 10.2 I just started using TVirtualStringTree and all is working well (Thanks Jam Software). I need to save all the node captions to a text file with the same format as TTreeview (tab character for indent level followed by caption string) so, at a later time, the file can be loaded and parsed. Has anyone done such a thing? Cheers, Mark Share this post Link to post
Fr0sT.Brutal 900 Posted January 31, 2022 I did not but see no problem here. Share this post Link to post
Mark- 29 Posted January 31, 2022 Hello, What I came up with for my needs. procedure SaveVTToFileLikeTTreeView(tree:TVirtualStringTree; const fName:string); var data:TVTABFetch; strList:TStringList; tmpNode:PVirtualNode; function CreateTabPrefix(count:integer):string; var i:integer; begin result:=''; for i:=0 to count -1 do result:=result + #09; //tab end; begin if (fName = '') then Exit; strList:=TStringList.Create; if not Assigned(strList) then Exit; try tmpNode:=tree.GetFirst; if not Assigned(tmpNode) then //if nothing, scram Exit; repeat data:=TVTABFetch(Pointer(tree.GetNodeData(tmpNode)^)); if Assigned(Data) then //safety strList.Add(CreateTabPrefix(tree.GetNodeLevel(tmpNode)) + data.caption); tmpNode:=tree.GetNext(tmpNode); until (not Assigned(tmpNode)); strList.SaveToFile(fName); finally strList.free; end; end; Cheers, Mark Share this post Link to post