I always do this (and do this quite often):
array of string TStringList, . Edit1Change Items , .
,
var
arr: array of string;
- ,
procedure TForm1.FormCreate(Sender: TObject);
begin
SetLength(arr, 3);
arr[0] := 'cat';
arr[1] := 'dog';
arr[2] := 'horse';
end;
procedure TForm1.Edit1Change(Sender: TObject);
var
i: Integer;
begin
ListBox1.Items.BeginUpdate;
ListBox1.Items.Clear;
if length(Edit1.Text) = 0 then
for i := 0 to high(arr) do
ListBox1.Items.Add(arr[i])
else
for i := 0 to high(arr) do
if Pos(Edit1.Text, arr[i]) > 0 then
ListBox1.Items.Add(arr[i]);
ListBox1.Items.EndUpdate;
end;
, Edit1.Text; Edit1.Text.
Pos(Edit1.Text, arr[i]) > 0
Pos(Edit1.Text, arr[i]) = 1
TStringList
TStringList,
var
arr: TStringList;
procedure TForm1.FormCreate(Sender: TObject);
begin
arr := TStringList.Create;
arr.Add('cat');
arr.Add('dog');
arr.Add('horse');
end;
procedure TForm1.Edit1Change(Sender: TObject);
var
i: Integer;
begin
ListBox1.Items.BeginUpdate;
ListBox1.Items.Clear;
if length(Edit1.Text) = 0 then
ListBox1.Items.AddStrings(arr)
else
for i := 0 to arr.Count - 1 do
if Pos(Edit1.Text, arr[i]) = 1 then
ListBox1.Items.Add(arr[i]);
ListBox1.Items.EndUpdate;
end;
, , , "bo" "Boston". ,
if Pos(AnsiLowerCase(Edit1.Text), AnsiLowerCase(arr[i])) > 0 then
if Pos(Edit1.Text, arr[i]) > 0 then