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

#include <vcl.h>
#pragma hdrstop

#include "TStringListAdd.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: TStringListAdd
// Method: Classes.TStringList.Add
// Method: Classes.TStringList.Find
// Method: Classes.TStringList.Sort
// Method: Classes.TStrings.AddStrings

// BeginCode
/*
This example uses a list box and a label on a form. When the
application runs, a string list object is created and three
strings are added to it. The Find method searches the 
strings to look for a match with the string ‘Flowers’. If
the string is found, all the strings in the string list are
added to the list box, and the index value of the ‘Flowers’
string appears in the caption of the label control.
*/

#include <memory>       //for STL auto_ptr class

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  int Index;
  std::auto_ptr<TStringList> MyList(new TStringList());
  MyList->Add("Animals");
  MyList->Add("Flowers");
  MyList->Add("Ocean");
  MyList->Sort(); // Find will only work on sorted lists
  if (MyList->Find("Flowers", Index))
  {
	ListBox1->Items->AddStrings(MyList.get());
	Label1->Caption = "Flowers has an index value of " + AnsiString(Index);
  }
}
// EndCode
// EndExample: TStringListAdd
//---------------------------------------------------------------------------
