Doug Steele
dbdoug at gmail.com
Mon Oct 6 10:58:15 CDT 2008
Hi Gustav: I took a bit of a liberty and submitted your question on StackOverflow. I hope you don't mind. I was curious to see what feedback (if any) I got for a vb question, as the site is very C# intensive. Anyway, here's the answer I got after half an hour or so: This is because the UserDeletingRow event is on the actual DataGridView. The DataGridView is bound to the external data (contained in your DataSet and linked by a BindingSource) as is the BindingNavigator. When you click delete on the BindingNavigator it is simply removing the current element selected in the BindingSource. You need to check the Click event on the delete button in the BindingNavigator and see where it is actually performing the delete to the BindingSource. You should be able to insert in a confirmation dialog between the delete item call and the click. Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click If MsgBox("Are you sure", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then DeleteSelectedItem() End If End Sub Doug Steele On Mon, Oct 6, 2008 at 1:18 AM, Gustav Brock <Gustav at cactus.dk> wrote: > Hi all > > The DataGridView has an event, UserDeletingRow, with the option to cancel > the delete caused by pressing the Delete button of the keyboard. > But if the user clicks the Delete toolstripbutton of the bindingnavigator, > no such event exists. Why? > > So what do you do to pop a messagebox asking the user to confirm to delete > the row? > >