How to do livebindings with objects and get the objects contained?

2

I have a problem that I can not solve at all. With Delphi XE8 , I have already done livebindings to connect components TEdit with non-visual objects, but I can not connect screen components with objects contained in other objects: Example:

TEstado = class
  FUF: string;
end;

TCidade = class
  FNome: string;
  FEstado: TEstado;
end;

In this case I can connect the city name with some screen component, but I can not get cidade.estado.uf to display on the screen.

    
asked by anonymous 16.07.2015 / 13:41

1 answer

1

To make the structure of your class available to LiveBinding use the "DataGeneratorAdapter" component. Create the properties of your class in it, from here you can connect your visual components to this structure.

After that, use the "AdapterBindSource" component to bind your class to this structure created in the "DataGeneratorAdapter". Program the "CreateAdapter" event as follows:

procedure TForm1.AdapterBindSource2CreateAdapter(Sender: TObject;
  var ABindSourceAdapter: TBindSourceAdapter);

begin

     FLista := TObjectList<TPessoa>.Create;
     FLista.Add(TPessoa.Create('Filipe', 25, '[email protected]'));
     FLista.Add(TPessoa.Create('Cíntia', 27, '[email protected]'));
     FLista.Add(TPessoa.Create('Julio', 32, '[email protected]'));
     ABindSourceAdapter := TListBindSourceAdapter<TPessoa>.Create(Self,     FLista);

end;
    
23.04.2016 / 20:03