unit Unit2;
interface
uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils, System.Variants, System.Classes, System.Generics.Collections, System.Generics.Defaults,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls, Data.Bind.Components, Data.Bind.ObjectScope, Data.Bind.GenData, Data.Bind.EngExt,
Vcl.Bind.DBEngExt, System.Rtti, System.Bindings.Outputs,
Vcl.Bind.Editors,
Vcl.ComCtrls;
type
TBlubb =
class
private
FID: Integer;
FDatum: TDateTime;
FText:
string;
FCheck: Boolean;
public
property ID: Integer
read FID
write FID;
property Text:
string read FText
write FText;
property Datum: TDateTime
read FDatum
write FDatum;
property Check: Boolean
read FCheck
write FCheck;
end;
TForm2 =
class(TForm)
edt1: TEdit;
lbl1: TLabel;
chk1: TCheckBox;
binadp1: TAdapterBindSource;
lv1: TListView;
bndlst1: TBindingsList;
genadp1: TDataGeneratorAdapter;
linproCaption: TLinkPropertyToField;
lnkcon1: TLinkControlToField;
lincon1: TLinkFillControlToField;
linproChecked: TLinkPropertyToField;
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure binadp1CreateAdapter(Sender: TObject;
var ABindSourceAdapter: TBindSourceAdapter);
private
FList: TObjectList<TBlubb>;
FBlubb: TBlubb;
public
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.binadp1CreateAdapter(Sender: TObject;
var ABindSourceAdapter: TBindSourceAdapter);
begin
FList := TObjectList<TBlubb>.Create(True);
// mußte hierher verschoben werden weil FormCreate nach dem CreateAdapter gefeuert wird. Sonst ist die Instanz nil.
FBlubb := TBlubb.Create;
FBlubb.ID := 100;
FBlubb.Text := '
BLA';
FBlubb.Datum := Now;
FBlubb.Check := True;
FList.Add(FBlubb);
ABindSourceAdapter := TListBindSourceAdapter<TBlubb>.Create(self, FList);
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
// FBlubb := TBlubb.Create;
// FBlubb.ID := 100;
// FBlubb.Text := 'BLA';
// FBlubb.Datum := Now;
// FBlubb.Check := True;
//
// FList.Add(FBlubb);
end;
procedure TForm2.FormDestroy(Sender: TObject);
begin
FList.Free;
end;
end.