elGringo Posted March 14, 2017 Share Posted March 14, 2017 Lets say we have tree connected to DB with simple id of record in Data, we cannot just delete the nodes, we should dispose pointers memory of Data of each Node. It is known that unitreeview doesn't have all methods of treeview. For example we don't have GetNext method for easy traversing... This way Ok only if all records loaded to UniTreeView. It is ok in my practice if tree has 100-200 nodes. If you need big tree it is better to load nodes on Expanding event dynamically. Maybe someone wll need it. I do it like this procedure DeleteNodeWithChildrenAndData(Node: TUniTreeNode); var TreeView:TUniTreeView; i: Integer; TempNode:TUniTreeNode; begin TempNode:=Node; TreeView:=MainForm.AdminFrame.GoodsFrame.TreeView; while Node.HasChildren do begin TempNode:=TreeView.Selected.GetLastChild; while TempNode.HasChildren do TempNode:=TempNode.GetLastChild; // do something here Dispose(TempNode.Data); DeleteRecordFromDB(TempNode); // TreeView.Items.Delete(TempNode); // end; //Deleting initial Node DeleteRecordFromDB(Node); Dispose(Node.Data); TreeView.Items.Delete(Node); end; Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted March 14, 2017 Administrators Share Posted March 14, 2017 If you need big tree it is better to load nodes on Expanding event dynamically. Setting LoadOnDemand will enable this feature. Quote Link to comment Share on other sites More sharing options...
elGringo Posted March 14, 2017 Author Share Posted March 14, 2017 Wow, didn't khow that! Thank's - will test it on days. Traditionally did it manually. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.