unit ViewMain;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Rtti, System.Classes,
System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs,
Data.Bind.GenData, Data.Bind.EngExt, FMX.Bind.DBEngExt, FMX.Bind.Grid,
System.Bindings.Outputs, FMX.Bind.Editors, Data.Bind.Components,
Data.Bind.Grid, FMX.Layouts, FMX.Grid, Data.Bind.ObjectScope,
Generics.Collections;
type
TPerson =
class
private
FFirstname:
string;
FLastname:
string;
FAge: Integer;
public
constructor Create(
const Firstname, Lastname:
string; Age: Integer);
published
property Firstname:
string read FFirstname
write FFirstname;
property Lastname:
string read FLastname
write FLastname;
property Age: Integer
read FAge
write FAge;
end;
TForm1 =
class(TForm)
AdapterBindSource1: TAdapterBindSource;
DataGeneratorAdapter1: TDataGeneratorAdapter;
Grid1: TGrid;
BindingsList1: TBindingsList;
LinkGridToDataSource1: TLinkGridToDataSource;
procedure AdapterBindSource1CreateAdapter(Sender: TObject;
var ABindSourceAdapter: TBindSourceAdapter);
private
MyPeople: TList<TPerson>;
// TObjectList
public
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
{ TPerson }
constructor TPerson.Create(
const Firstname, Lastname:
string; Age: Integer);
begin
FFirstname := Firstname;
FLastname := Lastname;
FAge := Age;
end;
procedure TForm1.AdapterBindSource1CreateAdapter(Sender: TObject;
var ABindSourceAdapter: TBindSourceAdapter);
begin
MyPeople := TObjectList<TPerson>.Create;
// TObjectList.Create
MyPeople.Add(TPerson.Create('
Fred', '
Flintstone', 40));
MyPeople.Add(TPerson.Create('
Wilma', '
Flintstone', 41));
MyPeople.Add(TPerson.Create('
Barney', '
Rubble', 40));
MyPeople.Add(TPerson.Create('
Betty', '
Rubble', 39));
// ABindSourceAdapter := TListBindSourceAdapter.Create
// (Self, MyPeople, True);
ABindSourceAdapter := TListBindSourceAdapter<TPerson>.Create
(AdapterBindSource1, MyPeople, True);
end;
end.