I'm trying to filter a listbox in Delphi using an Edit box, but it's not working. Here's my code based on the OnChange event of an Edit box.
procedure TReportDlgForm.FilterEditOnChange(Sender: TObject);
var
I: Integer;
begin
ListBox1.Items.BeginUpdate;
try
for I := 0 to ListBox1.Items.Count - 1 do
ListBox1.Selected[I] := ContainsText(ListBox1.Items[I], FilterEdit.Text);
finally
ListBox1.Items.EndUpdate;
end;
end;
I'm hoping that when I type in my edit box that the Listbox items will filter.
You must keep values from your list box in some variable and make search in this variable, not in ListBox items! In ListBox we only going to show result of search.