这个问题不止一个人问过,网上搜一下一大把。现给你复制一种方案:去掉DbGrid的自动添加功能 procedure TForm1.DataSource1Change(Sender: TObject; Field: TField); begin if TDataSource(Sender).DataSet.Eof then TDataSource(Sender).DataSet.Cancel; end;
ADOQuery使用批次更新模式。支持将所做的多条修改一次提交。 Specifies the lock type to use when opening a dataset.Delphi syntax:property LockType: TADOLockType;C++ syntax:__property TADOLockType LockType = {read=GetLockType, write=SetLockType, default=3};DescriptionUse LockType to specify the lock type to use when opening a dataset. LockType determines whether the row locking scheme for a recordset will be pessimistic, optimistic, or read-only. To be effective, LockType must be set prior to activating the ADO dataset component.The default value of LockType is ltOptimistic.Use the LockType ltBatchOptimistic to open a dataset in batch update mode.ltBatchOptimistic Optimistic batch updates; used for batch update mode rather than immediate update mode.
TField);
begin
if TDataSource(Sender).DataSet.Eof then
TDataSource(Sender).DataSet.Cancel;
end;
--------------------------------
应从数据集的state上考虑:换行,即从dsEdit变为dsBrowse状态
Specifies the lock type to use when opening a dataset.Delphi syntax:property LockType: TADOLockType;C++ syntax:__property TADOLockType LockType = {read=GetLockType, write=SetLockType, default=3};DescriptionUse LockType to specify the lock type to use when opening a dataset. LockType determines whether the row locking scheme for a recordset will be pessimistic, optimistic, or read-only. To be effective, LockType must be set prior to activating the ADO dataset component.The default value of LockType is ltOptimistic.Use the LockType ltBatchOptimistic to open a dataset in batch update mode.ltBatchOptimistic Optimistic batch updates; used for batch update mode rather than immediate update mode.
刚注意到是lihuasoft(类==大米),原来偶一直以为是lihuasoft(粪==大米)
如果不想换行保存,可以考虑用STRINGGRID!