 <p>While for this example it might be overkill here is a way to extend the TListView class with a SelectedItem property that is enumerable with a for-in loop.</p> <p>In cases where the condition inside the loop might be more complex than just checking a property or by actually providing a filter delegate this can be very powerful.</p> <pre><code>type TSelectedListItemsEnumerator = class(TListItemsEnumerator) public function MoveNext: Boolean; end; TSelectedListItemsEnumerable = record private FListItems: TListItems; public constructor Create(AListItems: TListItems); function GetEnumerator: TSelectedListItemsEnumerator; end; TListViewHelper = class helper for TListView private function GetSelectedItems: TSelectedListItemsEnumerable; public property SelectedItems: TSelectedListItemsEnumerable read GetSelectedItems; end; { TSelectedListItemsEnumerator } function TSelectedListItemsEnumerator.MoveNext: Boolean; begin repeat Result := inherited; until not Result or Current.Selected; end; { TSelectedListItemsEnumerable } constructor TSelectedListItemsEnumerable.Create(AListItems: TListItems); begin FListItems := AListItems; end; function TSelectedListItemsEnumerable.GetEnumerator: TSelectedListItemsEnumerator; begin Result := TSelectedListItemsEnumerator.Create(fListItems); end; { TListViewHelper } function TListViewHelper.GetSelectedItems: TSelectedListItemsEnumerable; begin Result := TSelectedListItemsEnumerable.Create(Items); end; </code></pre> <p>You can then use it like this:</p> <pre><code>procedure TForm1.Button1Click(Sender: TObject); var item: TListItem; begin for item in ListView1.SelectedItems do begin ShowMessage(item.Caption); end; end; </code></pre>