Domanda

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

È stato utile?

Soluzione

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;

Altri suggerimenti

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;

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top