typedef struct{
int a;
int b;
char c[1024];
}my_struct;
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender){
TAdvTreeViewNode *atn;
my_struct *ms;
AdvTreeView1->BeginUpdate();
AdvTreeView1->ClearColumns();
AdvTreeView1->ClearNodes();
AdvTreeView1->ColumnsAppearance->TopFont->Size = 8;
AdvTreeView1->NodesAppearance->Font->Size = 8;
AdvTreeView1->NodesAppearance->ExtendedFont->Size = 8;
AdvTreeView1->Columns->Add()->Text = "Column 1";
AdvTreeView1->Columns->Add()->Text = "Column 2";
AdvTreeView1->EndUpdate();
//root node
atn = AdvTreeView1->AddNode(NULL);
atn->Text[0] = _D("Node ") + IntToStr(atn->VirtualNode->Level);
atn->Text[1] = _D("Node ") + IntToStr(atn->VirtualNode->Level);
ms = new my_struct;
ms->a = 100;
ms->b = 101;
for(int i = 0; i < sizeof(ms->c); i++) ms->c = i;
atn->DataPointer = (my_struct *)ms;
atn = AdvTreeView1->AddNode(atn);
atn->Text[0] = _D("Node ") + IntToStr(atn->VirtualNode->Level);
atn->Text[1] = _D("Node ") + IntToStr(atn->VirtualNode->Level);
ms = new my_struct;
ms->a = 200;
ms->b = 201;
for(int i = 0; i < sizeof(ms->c); i++) ms->c = i;
atn->DataPointer = (my_struct *)ms;
atn = AdvTreeView1->AddNode(atn);
atn->Text[0] = _D("Node ") + IntToStr(atn->VirtualNode->Level);
atn->Text[1] = _D("Node ") + IntToStr(atn->VirtualNode->Level);
ms = new my_struct;
ms->a = 300;
ms->b = 301;
for(int i = 0; i < sizeof(ms->c); i++) ms->c = i;
atn->DataPointer = (my_struct *)ms;
AdvTreeView1->ExpandAll();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender){
AdvTreeView1->ClearNodes();
//after this i reconstruct AdvTreeView...
}
//---------------------------------------------------------------------------
When the button is pressed, the cleaning is performed in this case (but there can be only one branch cleaning). How do I clear all pointers to my_struct when clearing? There is an OnDeletion event in the Classic TreeView component... In this event, I deleted the pointer to the structure for each deleted node. And what about AdvTreeView?