-2

I have a TListBox called ListBoxPlayers, and I believe ListBoxPlayers.Items references the list of TStrings inside the TListBox. I am trying to use this function but it doesn't seem to work. Any ideas?

EDIT: So I'm trying to set the size of the TListBox dependent on how many strings it is going to display. Here's my code:

procedure TForm3.edtSearchChange(Sender: TObject);
begin
  ListBoxPlayers.Clear;
  if Length(edtSearch.text) > 0 then
     begin
        setSizeListBox((ListBoxPlayers.Items.Count));
        ListBoxPlayers.Visible:=true;
        dynamicSearch(edtSearch.Text)
     end
  else
     ListBoxPlayers.Visible:=false;
end;  

ListBoxPlayers.Items.Count always stays at 0 however many items there are in the list.

user2412643
  • 153
  • 1
  • 1
  • 13

1 Answers1

3

It should be the exact same as it appears, and the same way it works in Delphi:

NumberOfItems := ListBoxPlayers.Items.Count;

For looping:

for i := 0 to ListBoxPlayers.Items.Count - 1 do

Or

for i := 0 to Pred(ListBoxPlayers.Items.Count) do
Ken White
  • 123,280
  • 14
  • 225
  • 444