Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure FilterItems(const Text: string; ListBox: TListBox);
- var
- I: Integer;
- Hide: Boolean;
- Item: TListBoxItem;
- Head: TListBoxGroupHeader;
- begin
- Head := nil;
- Hide := True;
- ListBox.BeginUpdate;
- try
- for I := 0 to ListBox.Content.ControlsCount - 1 do
- begin
- if Text.IsEmpty then
- ListBox.ListItems[I].Visible := True
- else
- if ListBox.ListItems[I] is TListBoxGroupHeader then
- begin
- if Assigned(Head) then
- Head.Visible := not Hide;
- Hide := True;
- Head := TListBoxGroupHeader(ListBox.ListItems[I]);
- end
- else
- if ListBox.ListItems[I] is TListBoxItem then
- begin
- Item := TListBoxItem(ListBox.ListItems[I]);
- if Item.Text.ToLower.Contains(Text) then
- begin
- Hide := False;
- Item.Visible := True;
- end
- else
- Item.Visible := False;
- end;
- end;
- finally
- ListBox.EndUpdate;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement