Re: delete key in dbgridPosted by WAllison on May 16, 2002 at 19:47:54: In Reply to: delete key in dbgrid posted by abobby on May 16, 2002 at 16:41:01: : I have a dbgrid hooked to a table in delphi 5. I want to be able to hit the delete key and delete the contents in that field. the only way right now is by hitting the backspace key. What can I do to enable this to happen using the delete key : thanks Here is a way - no error checking though - you'll have to add code to make sure that recordcount > 0 etc etc procedure TMainForm.DBGrid1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin If key = VK_DELETE then begin If DataSource1.State in [dsBrowse] then DataSource1.DataSet.Edit; DBGrid1.SelectedField.Clear; DBGrid1.SelectedField.FocusControl; end; end; l8rz Waz |
|