Delphi 10.4.1 with FireMonkey.
I have 50 items on a TListView, with IDs from 1 to 50. No code posted here because I don't even know where to get started.
If I did a search for ID=35, is there a way to make
TListView move exactly to the position of that item programmatically
so that the item is in full view?
This is trivial:
ListView.ScrollTo(Item.Index);
In short: Set the SelectedItem and the list view scrolls to this element in the list.
In long: You can iterate through the list and select the item that matches your search criteria:
for var c := 0 to ListView1.ItemCount - 1 do
if ListView1.Items[c].Text = <TextToSearch> then
begin
ListView1.Selected := ListView1.Items[c];
break;
end;
Unfortunately, you do not explain how to save the ID in the list item. My example assumes that this is done in the list text. Alternatively you can also use e.g. Tag or TagString.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With