Is there an easy way with a TListView in report mode, to store a unique integer with each row? I've tried using the ".Data" property, but seem to end up with corruption quite often.
I'm trying to do this because I want to associate each row with a primary key ID from a database. At the moment I'm using a dynamically sized array, and adding the row id, to the db ID so I have to use, for example, rowsToIds[lv.SelectedIndex]; but it seems like a long-winded way to do it.
Is there an easier way to do this? Simple example of exactly what I'm trying to do...
procedure TForm1.FormCreate(Sender: TObject); var i: Integer; li: TListItem; begin for i := 0 to 50 do begin li := lv1.Items.Add; li.Caption := 'xyz'; li.SubItems.Add('abc'); //Store a unique integer with the row here... end; end; procedure TForm1.lv1DblClick(Sender: TObject); begin //Show the stored integer here... end;