Search code examples
c++buildervcl

Builder C++ Delete all sub node in TreeNode


How to delete all sub node in the some treenode?

TTreeNode* ParentNode = TreeView->Selected;
int countNode = ParentNode->Count;
for(int p=0; p<countNode-1; p++)
{
    ParentNode->Item[p]->Delete();
}

this code dosn't work!


Solution

  • Call DeleteChildren on the parent node:

    ParentNode->DeleteChildren();