简体   繁体   English

具有LiveBindings的FMX ListView

[英]FMX ListView with LiveBindings

I am developing an FMX (Android) app using a ListView in Delphi 10.2.3. 我正在使用Delphi 10.2.3中的ListView开发FMX(Android)应用程序。 I have the Listview live(bound) to a ClientDataSet with (Synch->*) . 我有(Synch->*)绑定到ClientDataSetListview live(绑定(Synch->*) This works very well, and any changes in Listview are propagated to the ClientDataSet , including the ClientDataSet's event handlers, such as BeforeUpdate , Post and AfterScroll . 这工作得很好,并且Listview中的任何更改都将传播到ClientDataSet ,包括ClientDataSet's事件处理程序,例如BeforeUpdatePostAfterScroll

Now when I move the record pointer in the ClientDataSet programmatically , the Listview does not synch with the change. 现在,当我以编程方式移动ClientDataSet中的记录指针时, Listview 不会与更改同步 It seems the Livebinding only works "one way" (from the UI to the Dataset). 似乎Livebinding仅以一种方式(从UI到数据集)起作用。

How can I make the Listview follow the ClientDataSet , the way it does in the VCL when using a DataSource? 如何使Listview遵循ClientDataSet ,就像使用DataSource时在VCL中那样?

// here I expect the see the selected item start at the first item 
// in the UI in index order and move quickly down through the 
// list until it stops at the last one. This doesn't happen. The UI remains
// unaffected.
ClientModule.CDSData.First;
while not ClientModule.CDSData.Eof do
begin
   ClientModule.CDSData.Next;
   Sleep(100);
end;

The easy answer to this question is to perform a 这个问题的简单答案是执行

if ClientModule.CDSData.Locate('PKID', VarArrayOf([PKIDValue]), []) then

It seems that while moving the record pointer using CDSData.Next doesn't sync back to the Live(Bound) Listview , using a locate does. 看来,在使用移动记录指针CDSData.Next不同步回直播(行) Listview ,使用locate一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM