Search code examples
visual-c++listviewwtl

How to get items from a ListViewCtrl multiple selection in WTL?


I have a ListViewCtrl in a WTL program.

I need to get the items selected by the user(multiple selection).

I can only het the count of selected items using GetSelectedCount().

GetSelectedItem() doesnt work with multiple selection.


Solution

  • Have a look here:

    CListViewCtrl ListView = ...
    for(INT nItem = ListView.GetNextItem(-1, LVNI_SELECTED); nItem >= 0; nItem = ListView.GetNextItem(nItem, LVNI_SELECTED))
    {
      // Here you go with nItem
    }