Board index » delphi » Saving TreeView with Data

Saving TreeView with Data

Hi !!!

        I am using Delphi2 to create a Tree using the TreeView component
(Win 95), with data structure associated to each node. I want to be able
to take a snapshot of the tree before doing any transaction (eg. delete,
add, or move node), so that I can UNDO any transaction, by loading back
the previous snapshot.
        I've been using the SaveToStream and LoadFromStream method of
the TMemoryStream Object. (See below):

        TreeView1.SaveToStream(MyStream); {save content of treeView                                     into
the Memory Stream}

        AND

        MyStream.Seek(0,0); {Load Saved Data back into Treeview}
        TreeView1.LoadFromStream(MyStream);

        It saves and loads the tree Ok, but it only saves & loads the nodes'
names not the data associated with each node. (???)

        I also found a ISTORAGE interface and IPERSISTSTORAGE (API), I
wonder if this works, if so, How?  Or are there better ways to do this.

Hung.

 

Re:Saving TreeView with Data


Hi Hung

Quote
Hung TRUONG wrote:

> Hi !!!

>         I am using Delphi2 to create a Tree using the TreeView component
> (Win 95), with data structure associated to each node. I want to be able
> to take a snapshot of the tree before doing any transaction (eg. delete,
> add, or move node), so that I can UNDO any transaction, by loading back
> the previous snapshot.
>         I've been using the SaveToStream and LoadFromStream method of
> the TMemoryStream Object. (See below):

>         TreeView1.SaveToStream(MyStream); {save content of treeView                                     into
> the Memory Stream}

>         AND

>         MyStream.Seek(0,0); {Load Saved Data back into Treeview}
>         TreeView1.LoadFromStream(MyStream);

>         It saves and loads the tree Ok, but it only saves & loads the nodes'
> names not the data associated with each node. (???)

>         I also found a ISTORAGE interface and IPERSISTSTORAGE (API), I
> wonder if this works, if so, How?  Or are there better ways to do this.

Have you tried Treeviw1.savetofile /Treeview1.loadfromfile ?

Quote

> Hung.

--
Regards

Chee Chong Hwa, aka C.H. Chee
Penang,MALAYSIA
e-mail : c...@pc.jaring.my
Who the heck Is Chee Chong Hwa ?
http://www.cch.com.my/cch/people/cch

Clipper...Clipper...Clipper
http://www.cch.com.my/cch/clipper

Delphi...Delphi...Delphi
http://www.cch.com.my/cch/delphi
<You're invited to download the KarenSoft Web Browser
   Version 1.03>

CCH SOFTWARE SOLUTION SDN. BHD.    
(soon to be known as KarenSoft Solutions Sdn Bhd)
http://www.cch.com.my/cch/cchss  

CCH WEB SERVICES SDN. BHD.
http://www.cch.com.my/cch

Re:Saving TreeView with Data


Quote
Hung TRUONG wrote:

> Hi !!!

>         I am using Delphi2 to create a Tree using the TreeView component
> (Win 95), with data structure associated to each node. I want to be able
> to take a snapshot of the tree before doing any transaction (eg. delete,
> add, or move node), so that I can UNDO any transaction, by loading back
> the previous snapshot.
>         I've been using the SaveToStream and LoadFromStream method of
> the TMemoryStream Object. (See below):

>         TreeView1.SaveToStream(MyStream); {save content of treeView                                     into
> the Memory Stream}

>         AND

>         MyStream.Seek(0,0); {Load Saved Data back into Treeview}
>         TreeView1.LoadFromStream(MyStream);

>         It saves and loads the tree Ok, but it only saves & loads the nodes'
> names not the data associated with each node. (???)

>         I also found a ISTORAGE interface and IPERSISTSTORAGE (API), I
> wonder if this works, if so, How?  Or are there better ways to do this.

> Hung.them. It is this re-indexing that causes the time delay. If your data is

organized you
could see quite a speed inprovement. The main point being the the tree is
re-indexed
each time you remove, move or add a node.
..tom..

Other Threads