When the user clicks the Delete button on a BindingNavigator, the delete occurs immediately.

I can arrange for the user to cancel the delete later, but that assumes the user realizes that a record was deleted in the first place, so I prefer to warn them when the button is clicked. I would like to display a dialog asking the user to confirm the delete operation before hand, and cancel the delete if the user does not confirm it. I have not identified a good way to do that.

The row is already deleted by the time the Click event on the button occurs.

The DataTable.RowDeleting event does not provide a Cancel property in DataRowChangeEventArgs.

Is there a way to trap this event

First thing you will do is
set BindingNavigator' s DeleteItem to none from the properties box
Doing this, the button will still show but the default event is gone.

Double click afterwards on the delete button and include a similar code like that,

private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Sure you wanna delete?", "Warning", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
               bindingSource1.RemoveCurrent();
        }

Excellent! I imagine that same trick can be used with the other buttons. I'll try it. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.