I have a TListView in a form and I would like to know the index of the selected item. I tried to find a method or a property of my TListView which gives that information but the only thing I found was lvClients.Selected
and it doesn't give the index of this item.
How to get the index of the selected item in my TListView?
Use the ItemIndex property.
A value of -1 indicates no selection.
From documentation:
Read ItemIndex to determine which item is selected. The first item in the list has index 0, the second item has index 1, and so on. If no item is selected, the value of ItemIndex is -1. If the list control supports multiple selected items, ItemIndex is the index of the selected item that has focus.
Use Index
property of Selected
item
if lvClients.Selected <> nil then
index := lvClients.Selected.Index;
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