Search code examples
listviewdelphifiremonkey

How to access an ItemAppearance from ListView in Delphi 10?


As shown in this image below, I need to select the value of the txtID field when clicking on the item in the ListView. How do I do that?

enter image description here


Solution

  • procedure TForm1.ListView1ItemClick(const Sender: TObject;
      const AItem: TListViewItem);
    begin
      showmessage(AItem.Objects[1].Data.AsString);  // Value of field
      showmessage(AItem.Objects[1].Name);  // Name of field
    
    // OR
    
      showmessage(AItem.Data['txtID'].AsString);  // Value of field
    end;