Delete warning with bindingnavigator

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

When I press the delete button on the BindingNavigator it deletes the record
without any warning. How can I add a warning dialog when the delete button
on the BindingNavigator is pressed and before the record is actually
deleted?

Thanks

Regards
 
Hi,

I wish the bindingnavigatordelete_click event allowed you to
cancel the delete of the row. If you are bound to a dataset you can add a
handler to the rowdeleted event and undo the delete. Not the best solution
but it works

AddHandler AdventureWorksDataSet.Tables(0).RowDeleted, AddressOf
Row_Deleting


Private Shared Sub Row_Deleting(ByVal sender As Object, _
ByVal e As DataRowChangeEventArgs)
If MessageBox.Show("Are you sure?", "", MessageBoxButtons.YesNo) =
Windows.Forms.DialogResult.No Then
e.Row.RejectChanges()
End If
End Sub

Ken
 
Doesn't seem to work for me. The msgbox never appears. I am using the
BindingNavigator. Do I need to change anything at that end?

Regards
 
Hi,

Try this instead. In the designer set the bindingnavigators
deleteitem to none. The delete button should still be there. Double click
on the delete button to get the code window to open up with the
BindingNavigatorDeleteItem_Click event open. Add the code below to control
the delete.

Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
BindingNavigatorDeleteItem.Click
If MessageBox.Show("Are you sure?", "", MessageBoxButtons.YesNo) =
Windows.Forms.DialogResult.Yes Then
ContactBindingSource.RemoveCurrent()
End If
End Sub




Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top