Delphi - Get current index of selected item in 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;