利用 Items.AddObject('name',Pointer(ID))给每列的Item加一个不同的ID,比如一列ID 为1
二列为2,查询时利用遍历分别对待各列,然后符合条件的 Selected.

解决方案 »

  1.   

    我试了一下,下面的这个函数可以满足你的需求;
    //=======
    procedure TForm1.Button1Click(Sender: TObject);
    var
      FindStr,tempstr:string;
      i,mCount:integer;
      mLis:TListItem;
      mCapStr,mSubStr1:TStringList;
    begin
      mCapStr:=TStringList.create;
      mSubStr1:=TStringList.create;  FindStr:=trim(edit1.text);
      mCount:=ListView1.Items.Count ;
      for i:=0 to mCount-1 do
        begin
          mLis:=TListItem.Create(ListView1.items);
          mLis:=ListView1.items.item[i];
          tempstr:=mLis.Caption ;
          mCapStr.Add(tempstr);
          tempstr:=mLis.SubItems[0];
          mSubStr1.Add(tempstr);
        end;
      if mCapStr.Find( FindStr,i) then
        showmessage(inttostr(i));
      if mSubStr1.Find(FindStr,i) then
        showmessage(inttostr(i));
    end;
    //===
    如有问题可以跟我联系:[email protected]