kbmmemtable 遍历

procedure TForm6.btn6Click(Sender: TObject);
var
  fld_Id:TIntegerField;
  fld_Value:TStringField;
  fld_Time:TDateTimeField;
  id:Integer;
begin
  //循环比较最小值
    cxGrid1DBTableView1.DataController.DataSource := ds1;
  ds1.DataSet := kbmtbl1;

  with kbmtbl1 do
  begin
    Open;
    fld_Id:=TIntegerField(FieldByName('Id'));
    fld_Value:=TStringField(FieldByName('Value'));
    fld_Time:=TDateTimeField(FieldByName('Time'));
    DisableControls;
    try
      First;
      id := fld_Id.AsInteger;
      while not Eof do
      begin
        if id > fld_Id.AsInteger then
        id := fld_Id.AsInteger;
        Next;
      end;
      Locate('Id',id,[]);
    finally
      EnableControls;
    end;
  end;
end;

posted @ 2017-03-12 10:26  夏天的西瓜君  阅读(322)  评论(0编辑  收藏  举报