Mega Code Archive

 
Categories / Delphi / ADO Database
 

Preventing deleting record in a DBGrid

Title: Preventing deleting record in a DBGrid Question: How to prevent deleting record in a DBGrid? Answer: Put the code below on the OnKeyDown event of the DBGrid. In fact it is really simple see the following... procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if (ssCtrl in Shift) and (Key = vk_Delete) then Key := 0; end;