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

#include <vcl.h>
#pragma hdrstop

#include "TListItemsInsert.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: TListItemsInsert
// Method: ComCtrls.TListItems.Insert
// Property: ComCtrls.TCustomListView.Selected
// Property: ComCtrls.TListItem.Index

// BeginCode
/*
The following example inserts a list item before the selected
item in the list view.  Place a TButton, a TEdit and a
TListView in the form.
*/ 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  TListItem *InsertItem;
  if (ListView1->Selected == NULL) return;
  InsertItem =
	ListView1->Items->Insert(ListView1->Selected->Index);
  InsertItem->Caption = Edit1->Text;
}

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";
}
// EndCode
// EndExample: TListItemsInsert
//---------------------------------------------------------------------------

