2017-02-27 32 views
0

TListView 및 TObjectList가 있습니다. TFoo.value를 Item에 바인딩합니다. 캡션. 내부에 showmessage가있는 "AfterScroll"프로 시저를 씁니다. TBindSourceAdapter.AfterScroll에 프로 시저를 연결합니다.Delphi : TListView에서 AfterScroll 라이브 바인딩

이 프로그램을 실행하면 하나의 showmessage 만 있습니다.

TListView를 TStringGrid로 대체하면 각 줄마다 showmessage가 있습니다.

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

그것은 뷰 TListView에에 "AfterScroll"이벤트를 연결할 수 있습니까? 내가 찾은

+0

의 "동기화"속성에 "*"바인딩이 VCL 또는 FMX를인가해야합니까? – MartynA

+0

VCL 및 FMX에 있습니다. – Joc02

+0

VCL TListView는 표준 Windows 컨트롤을 감싸는 래퍼이므로 VCL 코드를 q에 추가해야 독자가이 작업을 수행하는 방법과 어떻게 잘못 될지 알 수 있습니다. – MartynA

답변

0

, 우리는 뷰 TListView

enter image description here