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.
Es ist möglich, eine "Afterscroll" Ereignis auf einem TListView zu verbinden?
Ist dieser VCL oder FMX binden? – MartynA
Es ist in VCL und FMX. – Joc02
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