用locate是不能查找下一条记录的,你可以试试LocateNext

解决方案 »

  1.   

    locatenext怎么用?能举个例子吗
      

  2.   

    根据关键字的值先过滤,即可用next方法,然后再设过滤为false.笨办法:locate后用下面方法(按钮点击事件)function ToNext:boolean;
    var iPos:integer;
        KeyValue:variant;
    begin
      result:=false;
      iPos:=clientdataset1.RecNo;
      KeyValue:=clientdataset1.FieldValues['keyfield'];
      while iPos<clientdataset1.recordcount do
      begin
        inc(iPos);
        clientdataset1.RecNo:=iPos;
        if KeyValue=clientdataset1.FieldValues['keyfield'] then 
        begin
          result:=true;
          break;
        end;
      end;
    end;
      

  3.   

    哦,locatenext怎么用的我也记不清了,不过你可以用Findfirst找到第一个记录后,在用FindNext来向下移动指针!
      

  4.   

    同意steel1991(随想曲),用Locate每次都会从First开始找的一条匹配的记录,或者重载Locate函数使它从当前记录开始查找
      

  5.   

    下一条
    Query1.next;
    上一条
    Query1.prior;还有
    FindFirst, FindNext, FindCloseThe following example uses an edit control, a button, a string grid, and seven check boxes. The check boxes correspond to the seven possible file attributes. When the button is clicked, the path specified in the edit control is searched for files matching the checked file attributes. The names and sizes of the matching files are inserted into the string grid.
    procedure TForm1.Button1Click(Sender: TObject);var
      sr: TSearchRec;
      FileAttrs: Integer;
    begin
      StringGrid1.RowCount := 1;
      if CheckBox1.Checked then
        FileAttrs := faReadOnly
      else
        FileAttrs := 0;
      if CheckBox2.Checked then
        FileAttrs := FileAttrs + faHidden;
      if CheckBox3.Checked then
        FileAttrs := FileAttrs + faSysFile;
      if CheckBox4.Checked then
        FileAttrs := FileAttrs + faVolumeID;
      if CheckBox5.Checked then    FileAttrs := FileAttrs + faDirectory;
      if CheckBox6.Checked then
        FileAttrs := FileAttrs + faArchive;
      if CheckBox7.Checked then    FileAttrs := FileAttrs + faAnyFile;  with StringGrid1 do
      begin
        RowCount := 0;    if FindFirst(Edit1.Text, FileAttrs, sr) = 0 then    begin
          repeat
            if (sr.Attr and FileAttrs) = sr.Attr then
            begin
            RowCount := RowCount + 1;
            Cells[1,RowCount-1] := sr.Name;
            Cells[2,RowCount-1] := IntToStr(sr.Size);
            end;
          until FindNext(sr) <> 0;
          FindClose(sr);
        end;
      end;
    end;