Could someone help me with using VirtualTree in C++Builder?
I have VT1 with records in it:
And VT2 with records in it:
I copy values from VT1 to VT2:
void __fastcall TForm3::CopyItemsFromVT1ToVT2(TVirtualStringTree *VT_List, PVirtualNode NodeList, TVirtualStringTree *VT_Tree, PVirtualNode NodeTree) {
((PTreeData)VT_Tree->GetNodeData(NodeTree))->Id=((TForm1::PTreeData)VT_List->GetNodeData(NodeList))->Id;
((PTreeData)VT_Tree->GetNodeData(NodeTree))->Type=((TForm1::PTreeData)VT_List->GetNodeData(NodeList))->Type;
((PTreeData)VT_Tree->GetNodeData(NodeTree))->Date=((TForm1::PTreeData)VT_List->GetNodeData(NodeList))->Date;
((PTreeData)VT_Tree->GetNodeData(NodeTree))->Time=((TForm1::PTreeData)VT_List->GetNodeData(NodeList))->Time;
((PTreeData)VT_Tree->GetNodeData(NodeTree))->Char_Code=((TForm1::PTreeData)VT_List->GetNodeData(NodeList))->Char_Code;
((PTreeData)VT_Tree->GetNodeData(NodeTree))->Number_Code=((TForm1::PTreeData)VT_List->GetNodeData(NodeList))->Number_Code;
((PTreeData)VT_Tree->GetNodeData(NodeTree))->Message=((TForm1::PTreeData)VT_List->GetNodeData(NodeList))->Message;
}
How can I reference records from VT1 to VT2 instead? Is this correct?
((PTreeData)VT2->GetNodeData(ParentNodeTarget)) = ((PTreeData)VT1->GetNodeData(ParentNodeSource))


Instead of copying individual fields manually, you can let the compiler do it for you, assuming
TreeDatais astructorclasswith anoperator=implemented (particular a default one generated by the compiler), eg:But, if you want
VT2nodes to simply point at the same data asVT1nodes, without making copies, then you need to allocate theTreeDatainstances outside of any nodes, and then just storeTreeData*pointers inside of the nodes, eg: