1

I have a TListView and a TObjectList. I bind TFoo.value to Item.Caption. I write a procedure "AfterScroll" with a showmessage inside. I connect the procedure on TBindSourceAdapter.AfterScroll.

I run this program and I have just one showmessage.

If I replace TListView by TStringGrid, I have the showmessage on each lines.

type
    TFoo = class
    private
        FValue: string;
    public
        constructor create(sValue: string);
        property Value: string read FValue write FValue;
    end;

    TForm5 = class(TForm)
        PrototypeBindSource1: TPrototypeBindSource;
        StringGrid1: TStringGrid;
        BindingsList1: TBindingsList;
        LinkGridToDataSourcePrototypeBindSource1: TLinkGridToDataSource;
        ListView1: TListView;
        LinkFillControlToField1: TLinkFillControlToField;
        procedure PrototypeBindSource1CreateAdapter(Sender: TObject; var ABindSourceAdapter: TBindSourceAdapter);
    private
        { Déclarations privées }
        ListFoo: TObjectList<TFoo>;
        procedure AfterScrool(Adapter: TBindSourceAdapter);
    public
        { Déclarations publiques }
        constructor create(AOwner: TComponent); override;
    end;

var
    Form5: TForm5;

implementation

{$R *.fmx}
{ TForm5 }

procedure TForm5.AfterScrool(Adapter: TBindSourceAdapter);
begin
    ShowMessage('kk');
end;

constructor TForm5.create(AOwner: TComponent);
begin
    ListFoo := TObjectList<TFoo>.create();
    ListFoo.Add(TFoo.create('Test'));
    ListFoo.Add(TFoo.create('Test 1'));
    ListFoo.Add(TFoo.create('Test 2'));
    ListFoo.Add(TFoo.create('Test 3'));

    inherited create(AOwner);
end;

procedure TForm5.PrototypeBindSource1CreateAdapter(Sender: TObject; var ABindSourceAdapter: TBindSourceAdapter);
begin
    ABindSourceAdapter             := TListBindSourceAdapter<TFoo>.create(self, ListFoo);
    ABindSourceAdapter.AfterScroll := AfterScrool;
end;

{ TFoo }

constructor TFoo.create(sValue: string);
begin
    inherited create;
    FValue := sValue;
end;

end.

enter image description here

It is possible to connect an "AfterScroll" event on a TListView ?

Joc02
  • 345
  • 8
  • 18

1 Answers1

0

I found, we need to bind "*" on "Synch" property of TListView

enter image description here

Joc02
  • 345
  • 8
  • 18