1

My question relates to the use of Firemonkey TListView in Delphi 10.2 Tokyo.

I have a FMX form with a ListView with ItemAppearance.ItemApearance = which allows me to add any number of TTextObjectAppearance items.

The TListView has LiveBindings to TFDQuery fields via a TBindSourceDB. All my fields display as I want them to in the ListView.

I do not wish to display the primary key from that query to the user but I do want to be able to receive the primary key once the user selects an item in the listview.

The goal is to be able to locate the row in the TFDQuery dataset that contains other columns of information required to generate the next screen.

I would much appreciate your advice. Thanks in advance.

Jared Davison
  • 333
  • 3
  • 11
  • 1
    I think this [Q and A](https://stackoverflow.com/a/33657155/5043424) might be useful – asd-tm Nov 19 '17 at 16:16
  • And consider [this answer](https://stackoverflow.com/a/32009869/5043424) as well (link typo corrected) – asd-tm Nov 19 '17 at 16:24
  • 1
    Thank you very much @asd-tm that works! I will add an answer below based on [yours](https://stackoverflow.com/questions/31453018/how-to-get-item-lookupdata-and-selectedvalue-as-integer-of-an-fmx-tcombobox-at/33657155#33657155). – Jared Davison Nov 20 '17 at 12:55

1 Answers1

1

A solution for TListView based on asd-tm's comment worked for me.

For the original post see see this.

procedure TForm1.LinkFillControlToFieldPKFillingListItem(Sender:
    TObject; const AEditor: IBindListEditorItem);
begin
  (AEditor.CurrentObject as TListItem).Tag := FDQuery1.FieldByName('PK').AsInteger;
end;


procedure TForm1.ListView1ItemClick(const Sender: TObject; const
    AItem: TListViewItem);
begin
  FDQuery1.IndexFieldNames := 'PK';
  FDQuery1.SetKey;
  FDQuery1.FieldByName('PK').AsInteger := AItem.Tag;
  if FDQuery1.GotoKey then
    //...
end;     
Jared Davison
  • 333
  • 3
  • 11