我有一个名为 ListBoxPlayers 的 TListBox,我相信 ListBoxPlayers.Items 引用了 TListBox 内的 TStrings 列表。我正在尝试使用此功能,但它似乎不起作用。有任何想法吗?
编辑:所以我试图设置 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;
ListBoxPlayers.Items.Count
无论列表中有多少项目,始终保持为 0。