Ni idea, la verdad, sólo he pedido un ejemplo a la "IA Bard" y me ha dicho esto:
Código:
#include <vcl.h>
class TForm1 : public TForm
{
public:
TVirtualStringTree *Tree1;
__fastcall TForm1(TComponent* Owner);
void __fastcall FormCreate(TObject* Sender);
void __fastcall SortTree(int Column);
void __fastcall Tree1Sorted(TObject* Sender, TTreeNode* Node, bool& Continue);
};
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
Tree1 = new TVirtualStringTree(this);
Tree1->ColumnCount = 2;
Tree1->Columns[0]->Caption = "Nombre";
Tree1->Columns[1]->Caption = "Edad";
Tree1->AddChild(NULL, "Juan", 20);
Tree1->AddChild(NULL, "María", 25);
Tree1->AddChild(NULL, "Pedro", 30);
}
void TForm1::FormCreate(TObject* Sender)
{
SortTree(0);
}
void TForm1::SortTree(int Column)
{
Tree1->Sort(Column, true);
}
void TForm1::Tree1Sorted(TObject* Sender, TTreeNode* Node, bool& Continue)
{
if (Node->DataValue[0] < Node->Parent->DataValue[0])
Continue = false;
}
int main()
{
Application->Initialize();
Application->CreateForm(__classid(TForm1), &Form1);
Application->Run();
return 0;
}