Delphi 获取Lazarus中TStrings列表的长度

Delphi 获取Lazarus中TStrings列表的长度,delphi,pascal,lazarus,tlistbox,Delphi,Pascal,Lazarus,Tlistbox,我有一个名为ListBoxPlayer的TListBox,我相信ListBoxPlayer.Items引用了TListBox中的Tstring列表。我试图使用函数,但它似乎不起作用。有什么想法吗 编辑: 因此,我试图根据要显示的字符串数设置TListBox的大小。这是我的密码: procedure TForm3.edtSearchChange(Sender: TObject); begin ListBoxPlayers.Clear; if Length(edtSearch.text) &

我有一个名为ListBoxPlayer的TListBox,我相信ListBoxPlayer.Items引用了TListBox中的Tstring列表。我试图使用函数,但它似乎不起作用。有什么想法吗

编辑: 因此,我试图根据要显示的字符串数设置TListBox的大小。这是我的密码:

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;  

无论列表中有多少项,ListBoxPlayer.Items.Count始终保持为0。

它应该与显示的内容完全相同,并且与Delphi中的工作方式相同:

NumberOfItems := ListBoxPlayers.Items.Count;
对于循环:

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


定义“似乎不起作用”。显示您的代码。它始终为0。我已经更新了我的密码。哈哈,我是个白痴。忘记删除ListBoxPlayer。请从一开始清除。谢谢
for i := 0 to Pred(ListBoxPlayers.Items.Count) do