procedure TForm1.btnDoSumClick(Sender: TObject);
var
i: Integer;
begin
if DBGrid1.SelectedRows.Count > 0 then
begin
with DBGrid1.DataSource.DataSet do
begin
for i := 0 to DBGrid1.SelectedRows.Count-1 do
begin
GotoBookmark(Pointer(DBGrid1.SelectedRows.Items[i]));
self.ADOQuery1.Delete;//删除记录
end;
end;
end
end;
我的这段程序是这样的.
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage('删除前记录数:'+IntToStr(ADOQuery1.RecordCount));
try
DBGrid1.SelectedRows.Delete;
except
end;
ADOQuery1.Close;
ADOQuery1.Open;
ShowMessage('删除后记录数:'+IntToStr(ADOQuery1.RecordCount));
end;