Mega Code Archive

 
Categories / Delphi / ADO Database
 

Stop auto appending from DBGrid

Title: Stop auto-appending from DBGrid Question: How to stop the dbgrid control from auto-appending a new entry when you move down after the last record in a table. Answer: Add to your TTables's "BeforeInsert" event the following line: procedure TForm1.Tbable1BeforeInsert(DataSet: TDataset); begin Abort; end; OR procedure TForm8.DBGrid1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if (Key = VK_DOWN) then begin TTable1.DisableControls ; TTable1Next ; if TTable1.EOF then Key := 0 else TTable1.Prior ; TTable1.EnableControls ; end ; end;