简体   繁体   中英

How to get the values of TListView selected item in Firemonkey Delphi Rio

I have a TListView populated with data from TFDQuery using Livebindings.

I would like to get the values of the selected item like the item.text, itemheader.text, etc. I already figured out the selected item through listview1.itemindex but to get the values is a struggle to me. I am new with TListView and livebindings. I've spent over a day already looking for answers in the internet but looks too complicated for a very simple task. I know there is a straight method for this.

Anyone care to share some clues (codes) on how to get the values of listview selected item?

MORE DETAILS:

I am using the Livebindings dynamic appearance. I created items for my query fields and map them accordingly to my TListView.

It so happen that I did not use the default item.text but instead map fields to my created items like item.text1, item.text2, item.item3.

Hence, this is the reason why I am not getting the caption from the formula given by MartynA below.

Perhaps I am missing your point (in which case I'll delete this) but the following FMXcode works fine for me:

procedure TForm1.Button2Click(Sender: TObject);
var
  Index : Integer;
begin
  Index := ListView1.ItemIndex;
  if Index >= 0 then
    Caption := ListView1.Items[Index].Text;
//  OR  ShowMessage(ListView1.Items[Index].Text);
//  OR  Label1.Text := ListView1.Items[Index].Text;

end;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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