2017-02-27 3 views
0

Ich habe eine TListView und eine TObjectList. Ich binde TFoo.value an Item.Caption. Ich schreibe eine Prozedur "AfterScroll" mit einer showmessage innerhalb. Ich verbinde die Prozedur auf TBindSourceAdapter.AfterScroll.Delphi: Livebindings AfterScroll auf TListView

Ich führe dieses Programm und ich habe nur eine showmessage.

Wenn ich TListView durch TStringGrid ersetzen, habe ich die showmessage auf jeder Zeile.

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

Es ist möglich, eine "Afterscroll" Ereignis auf einem TListView zu verbinden?

+0

Ist dieser VCL oder FMX binden? – MartynA

+0

Es ist in VCL und FMX. – Joc02

+0

Die VCL-TListView ist ein Wrapper um die Standard-Windows-Steuerung, daher denke ich, dass Sie Ihren VCL-Code zu Ihrem q hinzufügen müssen, damit die Leser sehen können, wie Sie dies versuchen und wie es schief gehen könnte. – MartynA

Antwort

0

fand ich, müssen wir "*" auf "Synch" Eigentum von TListView

enter image description here

Verwandte Themen