function TForm1.Button1Click(Sender:TObject)
var 
i:integer;
begin
    for i = 0 to ListBox1.Items.Count
    begin
      if(ListBox1.Selected[i]) then
      begin
        ShowMessage('found');
break;
      end;
   end;
end;

解决方案 »

  1.   

    will是回答应该是正确的,但for循环应该是for i=0 to ListBox1.Items.Count-1 do;吧?
    吹毛求疵了。
        
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
    i:integer;
    begin
        for i:=0 to ListBox1.Items.Count-1 do
        begin
          if(ListBox1.Selected[i]) then
          begin
            ShowMessage('found');
            break;
          end;
         end;
    end;
      

  3.   

    如果仅仅想知道ListBox中是否有被选者的项目,应该是
    if ListBox1.SelCount >0 then
       ShowMessage(IntToStr(ListBox1.SelCount)+' items selected')
    else
       ShowMessage('no item selected');