怎么让DBGrid中只有满足条件的记录才能被修改,而其它的修改无效?

解决方案 »

  1.   

    使用SQL语句的Update+Where可以实现按条件修改
      

  2.   

    要是在GRID里直接改的话,不好控制好像,dxDBGrid或GridEH里还说弄些.
      

  3.   

    AdoQuery.onBeforeEdit  if AdoQuery.FieldByName('Posted').value = '1' then 
      begin
        ShowMessage('单据审核,不能修改!');
        ??.SetForce
        abort;
      end;
      

  4.   

    先把DBGrid中的readonly = true
    然后在OnDragDrop事件中判断如果满足条件就
    把readonly = false
    当不满足条件的时候readonly = true
      

  5.   

    procedure TForm1.DBGrid1DblClick(Sender: TObject);
    begin
      if DM.ADOQuery1.FieldByName('aa').asstring = 'aa' then
      begin
        DBGrid1.ReadOnly := false;
      end;
      if DM.ADOQuery1.FieldByName('aa').asstring <> 'aa' then
      begin
        DBGrid1.ReadOnly := true;
      end;
    end;
      

  6.   

    AdoQuery.OnBeforeEdit可以处理这个事件来判断是否修改