Oli999
asked on
store a record in TTreeNode data property
Hello.
Am writing an application that contains a large TTreeView and wish to store some data against every node in the tree of complex data type.
Have figured out how to do this with a simple data types like integer and string but can't get it working with a record.
I can see why the sample of code below crashes, but can't figure out how to get it working. Please can anyone help?
type
PTestType = ^TTestType;
TTestType = record
str1,str2 : string;
end;
procedure TForm1.Button1Click(Sender : TObject);
begin
PTestType(TreeView1.Items. Item[0].da ta).str1:= 'hello1'; //crashes here with "access vioaltion"
PTestType(TreeView1.Items. Item[0].Da ta).str2:= 'hello2';
showmessage(PTestType(Tree View1.Item s.Item[1]. Data).str1 );
showmessage(PTestType(Tree View1.Item s.Item[1]. Data).str2 );
end;
Am writing an application that contains a large TTreeView and wish to store some data against every node in the tree of complex data type.
Have figured out how to do this with a simple data types like integer and string but can't get it working with a record.
I can see why the sample of code below crashes, but can't figure out how to get it working. Please can anyone help?
type
PTestType = ^TTestType;
TTestType = record
str1,str2 : string;
end;
procedure TForm1.Button1Click(Sender
begin
PTestType(TreeView1.Items.
PTestType(TreeView1.Items.
showmessage(PTestType(Tree
showmessage(PTestType(Tree
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome. Good luck.
ASKER
Thanks very much Aydin, this was what I needed. Much appreciated.