1,在DBGRID一次添加多条记录保存,在保存完成后,只显示保存了最后一条记录。是什么原因?2,procedure TBuyForecaseFrm.DBGrid1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  if FOpenType<> otView then  //otView 浏览状态
    begin
      if Key =  VK_DOWN   then //小键盘的 向下键
        begin
          if  DBGrid1.DataSource.DataSet.Eof then
           begin
           {
             FDataList[0].Insert;
             FDataList[0]['ZREC_ID']:= '1';
             dbeOrder.Text:=inttostr(FDataList[0].RecordCount+1);
             MoudleEdit.Text:='';
             }           end;
        end;
    end else
      MessageMe('浏览状态下不能增加数据!');
end;      {
             FDataList[0].Insert;
             FDataList[0]['ZREC_ID']:= '1';
             dbeOrder.Text:=inttostr(FDataList[0].RecordCount+1);
             MoudleEdit.Text:='';
             }
光标在DBGRID最后一条记录时,按向下键
这部分代码,为什么始终不执行?我是想光标在DBGRID最后一条记录时,按向下键,执行{}中的 这部分代码

解决方案 »

  1.   

    光标在DBGEID最后一行的 时候,始终是 DBGrid1.DataSource.DataSet.Eof为FALSE把下面的代码放到dsForecaseDataChange(Sender: TObject;
      Field: TField);就可以了
              if  DBGrid1.DataSource.DataSet.Eof then 
              begin 
              { 
                FDataList[0].Insert; 
                FDataList[0]['ZREC_ID']:= '1'; 
                dbeOrder.Text:=inttostr(FDataList[0].RecordCount+1); 
                MoudleEdit.Text:=''; 
                }           end;