实时刷新DBGrid控件,当点击某一行时可以进行编辑并要求刷新一遍dbgrid后重新定位到该行!

解决方案 »

  1.   

    先记录记录号RecNo;
    刷新;
    再GoTo(RecNo);
    *注:对于索引字段的更新不能采用此方法
      

  2.   

    var vRecNo : Integer;
    begin
      vRecNo := ADOQuery1.RecNo;
      //刷新数据
      ADOQuery1.Close;
      ADOQuery1.Open;
      if ADOQuery1.RecordCount >= vRecNo then
        ADOQuery1.RecNo := vRecNo;
    end;
     
      

  3.   


    procedure TForm1.DBGrid1CellClick(Column: TColumn);
    begin
      //刷新数据
      vRecNo := ADOQuery1.RecNo;
      ADOQuery1.Refresh;
      if ADOQuery1.RecordCount >= vRecNo then
        ADOQuery1.RecNo := vRecNo;
    end;
      

  4.   

    你的数据集假设有个关键字IDvar
      i:String;
    begin
      //刷新前
      i:=AdoQuery1.FieldBYName('ID').AsString;
      AdoQuery1.DisabControls;
      AdoQuery1.Requery;
      AdoQuery1.Locate('ID',i,[loCaseInsensitive]);
      AdoQuery1.EnableControls;
    end;
      

  5.   

    使用TClientdataset的reflash功能
      

  6.   

    用书签吧,也不知道下面这段程序能不能帮你上
    var ch:string;
      s:TBook;
    begin
     if key=13 then
      begin
       //he:=he-(ki-table1.fieldbyname('err_qty').asinteger);
       with  Table1 do
       begin
          S := GetBook;   //给书签赋值,就是你要回来的地方
        try
          FindPrior;                  //执行处理操作
          active:=false;
          active:=true;
          GotoBook(S);    //回到设置书签的地方
          next;
        finally
          FreeBook(S);    //释放书签
        end;
        end;
       //edit1.text:=inttostr(he);
       //edit2.Text:=table1.fieldbyname('err_qty').AsString;
      end;
    end;
      

  7.   

    我现在用locate方法可以实现功能了,但我有一点不明白,
    i:=adoquery.fieldbyname('id').asstring;
    refreshDB;
    adoquery.locate('id',i,[]);
    我点击哪一行都可以取得相应的id值,是不是DBGrid控件自己感知的?另外,用书签我也试过了,效果不好,老是做循环遍历,让程序死掉