Board index » delphi » Stopping Ctrl & Delete

Stopping Ctrl & Delete

Hi All

Delphi 4 with Paradox tables

I have noticed that a user can push the Ctrl & Delete keys to be given the
option to delete a record on a DbGrid.... I need to be able to disable this
feature,  but still leave the data set in edit mode for editing of certain
records. How is this done?

Thanks for yout time and help.

Please note: also posted in nativeapi newsgroup but no response in 2 days so
please excuse my re-post here (which on reflection is the correct newsgroup
anyway!)

Regards

Glenn
Key-Data Systems

 

Re:Stopping Ctrl & Delete


Create a BeforeDelete event handler and add the following line of
code.

SysUtils.Abort;

Raising any exception in any of the Before... event handlers blocks
the action.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

Re:Stopping Ctrl & Delete


Quote
> I have noticed that a user can push the Ctrl & Delete keys to be given the
> option to delete a record on a DbGrid.... I need to be able to disable
this
> feature,  but still leave the data set in edit mode for editing of certain
> records. How is this done?

Write an OnKeyDown event handler for the grid component and cancel that key
combination:
  if (Key = VK_DELETE) and (ssCTRL in Shift) then
    Key := 0;

Also you may instead write an OnBeforeDelete event handler to prevent
deletion of records at all. In this case bring out dgConfirmDelete from
dbgrid's options.

Other Threads