7

Can I abort deletion of record based on decisions after dbnavigator delete button pressed? I checked beforeAction Event

if Button = nbDelete then  
  //check if not OK then

Button := nbCancel;

but it doesn't work. Any Help?

I'm using DelPhi XE2, anyDac Components

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
ae1080
  • 374
  • 2
  • 7
  • 14

3 Answers3

3

Use the BeforeAction event

procedure TForm1.DBNavigator1BeforeAction(Sender: TObject; Button: TNavigateBtn);
begin
  if Button = nbDelete then
  begin
    if MessageDlg('Confirm delete now?', mtConfirmation, [mbYes,mbNo], 0) = mrNo then
    begin
      Abort;
    end;
  end;
end;
dataol
  • 999
  • 3
  • 19
  • 42
2

You can use the BeforeDelete event:

procedure Tdm.MyDataSetBeforeDelete(DataSet: TDataSet);
begin
  if SomeCondition then
  begin
    ShowMessage('Sorry, you can not delete this record.');
    Abort;
  end;
end;
mjn
  • 36,362
  • 28
  • 176
  • 378
0

Select the DBNavigator, then on the Object Inspector inside the Options set the noConfirmDelete to "false"

azios
  • 1