How to Backup and Restore the content of a TreeView (Views: 14)
How can I backup (save) and the restore (load) the content of my TreeView to a file?
Use the following two procedures to Backup and Restore the content of your TreeView:
procedure TForm1.BackupTreeView(MyTree: TTReeView; ToFile: string);
with TFileStream.Create(ToFile, fmCreate) do
procedure TForm1.RestoreTreeView(MyTree: TTReeView; FromFile: string);
with TFileStream.Create(FromFile, fmOpenRead) do
This approach will not keep any data associated with the nodes, you need take care about that separately. The only thing it will do is preserve the tree structure and node names. You also will not be able to restore the treeview to any other component than original one (say to the other form) without risking to screw up everything.
<< Back to main page