The event you are looking for is OnSelectItem
. It fires once for the item being de-selected, and again for the item being selected.
procedure SelectItem(Sender: TObject; Item: TListItem; Selected: Boolean);
Here, Sender
is the list view control, Item
is the item being selected or de-selected, and Selected
indicates whether this is selection or de-selection.
If you want to block selection change then OnChanging
is indeed the event you need. Check the Change
parameter. It has value ctState
when the selection is changing. Set the AllowChange
parameter to False
to block the change.