22
Answers

How to abort delete action on confirmation message box

Ask a question
Dealy

Dealy

14y
16.8k
1
Hello,

I have the code for deleting a record but i noticed even though user cancels the action it removes the current record from the form.

Any ideas how can i stop the action when user cancel the action on the confirmation message box?

  private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {

            if (MessageBox.Show("Delete?", "Confirm Delete", MessageBoxButtons.OKCancel) == DialogResult.OK)
            MessageBox.Show("DELETE");
            else
            {
//Code for Cancel action
             MessageBox.Show("ABORT");
            }
       }


Thank you in advance.

Answers (22)