0

I have a Delphi-Firemonkey-Android program. It has a TListBox, named lst1 and a database query. I hooked it up with live bindings like this:

This is what I have in LiveBindings

What I do is select an item in the listbox, then some processing in the Db, and finally close and open the query. Now the list will scroll to the top, but I want to keep the selected item in the listbox.

I know I can get the selected DeliveryId (which is unique per item) in the Listbox by readig:

lfc2fDelivery.BindList.GetSelectedValue.AsVariant

But how do I select the item corresponding the DeliveryId I saved before closing and opening the dataset? GetSelectedValue is readonly and it wont help relocate the query.

Thanks in advance

Mattias C
  • 23
  • 2
  • Do a `.Locate()` on the query passing the field(s) and key(s). If a matching record is found, then this record becomes current and Locate returns True. – Brian Oct 03 '18 at 19:42
  • Good thought @Brian, it is what I tested first. Also it is what I meant by relocate above. The listbox doesent reflect the change of active record in the query. That is why I want to write the selected value to the bindlist. In order to move focus to the correct item in the listbox. – Mattias C Oct 04 '18 at 07:02

0 Answers0