Add method
|
acStringListContainer component.
|
function Add(const S: String): Integer;
|
The Add method adds a new string to the list.
|
|
Call Add to add the string S to the end of the list. If the list is not sorted, S is added to the end of the list. Add returns the position of the item in the list, where the first item in the list has a value of 0.
|
|
The Add adds the string to the end of the list. If you would like to insert the string to some particular position of the list use Insert method instead.
|
|
Add will raise an EListError exception if the string S already appears in the list and Duplicates is set to dupError. If Duplicates is set to dupIgnore, trying to add a duplicate string does nothing.
|
|
Note that the list can't contain more strings than the number specified in the MaxSize property. For example, if MaxSize = 100 and you're trying to add 101st string, the first string will be deleted from the list to allow the new string to be added.
|
procedure TForm1.FormCreate(Sender: TObject);
|
var
|
MyList: TacStringList;
|
Index: Integer;
|
begin
|
MyList := TacStringList.Create;
|
try
|
MyList.Add('Animals');
|
MyList.Add('Flowers');
|
MyList.Add('Cars');
|
|
if MyList.Find('Flowers', Index) then
|
begin
|
ListBox1.Items.AddStrings(MyList);
|
Label1.Caption := 'Flowers has an index value of ' + IntToStr(Index);
|
end;
|
finally
|
MyList.Free;
|
end;
|
end;
|
Insert and AddStrings methods;
|
Duplicates and MaxSize properties;
|
OnChange event.
|