TMSFNCTreeview SaveToStream, LoadFromStream

Dear TMS Team,
I have two TMSFNCTreeView on my form. In the first treeview I create a menu tree. In this tree I select some entries. The nodes also use the node variable "DataString, DataInteger". In these variables I store values that are later used for program control.
After Selection I create a stream from this tree (TV1.SaveToStream(stream)).
In the second tree I now load this stream (TV2. LoadFromStream(stream)).
This works perfectly. I see the newly created tree only with the entries I selected in the first tree.
What is not copied, however, are the data from "node.DataInteger", "node.DataString". These variable fields are after the SaveStream and LoadStream on 0, respectively empty string.
Here is the source code of saving and loading the stream:

procedure TForm11.btnCopyTreeClick(Sender: TObject);
var
stream: TMemoryStream;
begin
stream:=TMemoryStream.Create;
try
createUserTree.saveToStream(stream);
stream.Position:=0;
tvUser.LoadFromStream(stream);
finally
stream.free;
end;
end;

Can you help me, or are these variables not copied with SaveStream and LoadStream??

This is by design, the Data* properties are used to temporarily assign data, they cannot be persisted.

Okay. Thank you Pieter.
I found another solution for this. I created two additional columns, which I set to "visiblle:=false".
Have a nice day for the whole team.

1 Like

Thanks Andreas!