//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "GetNextItem.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: GetNextItem
// Method: ComCtrls.TCustomListView.GetNextItem

// BeginCode
/*
This example demonstrates how to retrieve all selected items
in a ListView component and add the Caption of the selected
ListItems to a ListBox component.
Add a button, a listview, and a listbox to the form.
*/ 
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  TListItem *ListItem;
  ListView1->ViewStyle = vsList;
  ListItem = ListView1->Items->Add();
  ListItem->Caption = "Apples";
  ListItem = ListView1->Items->Add();
  ListItem->Caption = "Oranges";
  ListItem = ListView1->Items->Add();
  ListItem->Caption = "Pears";
}

void __fastcall TForm1::Button1Click(TObject *Sender)
{
   TItemStates selected = TItemStates() << isSelected;
   TListItem *Item = ListView1->Selected;
   while (Item){
      ListBox1->Items->Add(Item->Caption);
      Item = ListView1->GetNextItem(Item, sdAll, selected);
   }
}
// EndCode
// EndExample: GetNextItem

//---------------------------------------------------------------------------
