Protect DBPlanner from accidental deleting item

Hi
I'm trying to find a way to force a confirmation when a user tries to delete an item in the TDBPlanner.
At present, if they select an item and press delete key on the keyboard, the item is immediately deleted. I want to bring up a confirmation dialog before the delete takes place ("Are you sure you want to delete this item?")

There is an OnItemDelete event for the DBPlanner, but believe that this fires after the item is deleted?

Thanks for your help to resolve



To prevent the item from being deleted, call Abort in the OnItemDelete event.

procedure TForm4.Planner1ItemDelete(Sender: TObject; Item: TPlannerItem);
begin
  if MessageDlg('Delete?',mtConfirmation, [mbYes, mbNo],0) = mrNo then
    Abort;
end;

Bruno, thanks for your fast reply. That has worked perfectly.

I did not find ItemDelete described in my copy of 
TMS TPLANNER.pdf
or
TMS Planners Developers Guide.pdf
Perhaps that could be added for the next release.

Thanks again

Regards

Trevor


Hello Support Team
as a further step, how do I stop a new item being inserted?

If the user clicks on the planner and presses the insert key it inserts a new item.

I cannot disable the entire planner because the vertical scroll function still needs to work.

How can I check for a flag and not allow an Insert unless the flag is set (e.g. user has privileges)

I tried this but it didn't seem to work. The new item was always inserted:
procedure TPlannerForm.DBPlanner1ItemInsert(Sender: TObject; Position, FromSel,
  FromSelPrecise, ToSel, ToSelPrecise: Integer);
begin
if (not EditorEnabledChk.Checked) then  Abort;
end;

Thanks

If automatic insert of items cannot always be done in your Planner, I'd suggest to set Planner.AutoInsDel = false and handle OnPlannerKeyDown from where you handle the INS key at application level to either insert or not insert an item.