delphi中如何使用ListBox

来源:百度知道 编辑:UC知道 时间:2024/05/13 09:45:26
procedure TForm1.ListBox1DblClick(Sender: TObject);
begin
if ListBox1.Items:= '1000' then
ShowMessage('1000');

end;

当双击ListBox1中的1000的时候弹出1000 ,上面这段代码哪错了?

其中 if ListBox1.Items:= '1000' then 中有两个错误。
第一:判等的时候直接用“=”号,前面不加加“:”号
第二:Items对象下面还有属性,不能直接写 Items等于什么。
正确的写法为:if ListBox1.Items[0].text= '1000' then

[0]里面的0是索引号。