Ver Mensaje Individual
  #3  
Antiguo 09-01-2019
Avatar de Angel.Matilla
Angel.Matilla Angel.Matilla is offline
Miembro
 
Registrado: ene 2007
Posts: 1.350
Reputación: 19
Angel.Matilla Va por buen camino
Bueno. Otra vuelta de tuerca. Me ha pasado Casimiro Notevi un codigo en Delphi para ver si me voy enterando de como funciona este interesantre elemento. De momento sólo tengo en el formulario un TVirtualStringTree que pretendo cargar con un query desde un vista en FB. EL código que tengo puesto es este:
Código PHP:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
#include "Menu.h"
//---------------------------------------------------------------------------

#pragma package(smart_init)
#pragma link "VirtualTrees"
#pragma resource "*.dfm"
TForm1 *Form1;

AnsiString cAux;

extern void ColorForm(TForm *Formbool lAuto true);
//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponentOwner)
     : 
TForm(Owner)
{
     
ColorForm(this);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormClose(TObject *SenderTCloseAction &Action)
{
     
Action caFree;
     
Form1 NULL;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
     
PTreeData Dato;
     
PVirtualNode Nodo;

     
VST->Clear();
     
VST->NodeDataSize sizeof(TTreeData);

     
fMenu->Query->Close();
     
fMenu->Query->SQL->Text "SELECT Municipio, Codigo FROM Dl01 WHERE CodPrv = (SELECT Literal FROM Instalacion WHERE Etiqueta = 'Provincia') ORDER BY 1";
     
fMenu->Query->Open();

     for (; !
fMenu->Query->EoffMenu->Query->Next())
     {
          
cAux fMenu->Query->FieldByName("Municipio")->AsString;

          
Nodo VST->AddChild(NULL);
          
Dato = (PTreeDataVST->GetNodeData(Nodo);
          
Dato->Caption cAux;
     }
}
//--------------------------------------------------------------------------- 
Y el fichero de cabecera:
Código PHP:
//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "VirtualTrees.hpp"
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:    // IDE-managed Components
     
TVirtualStringTree *VST;
     
void __fastcall FormClose(TObject *SenderTCloseAction &Action);
     
void __fastcall FormCreate(TObject *Sender);
private:    
// User declarations
public:        // User declarations
     
__fastcall TForm1(TComponentOwner);
};

typedef struct tagTTreeData
{
     
AnsiString Caption;
TTreeData, *PTreeData;
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif 
El query funciona a la perfección y da este resultado:

Sin embargo tras ejecutar el código que he puesto, el resultado es este:


Como podéis ver en ningún sitio del codigo aparece el literal Node. Además no entiendo por qué rellena todas las columnas del TreeView. ¿Alguno me puede dar una pista?
Responder Con Cita