Ver Mensaje Individual
  #6  
Antiguo 18-09-2023
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.043
Reputación: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
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;
}
Responder Con Cita