cancel binding navigator click events


M

mr_doles

I don't get how to cancel a navigator click event.

I wrote a sub that handles BindingNavigatorMovePreviousItem.Click. I
do some validation in this routine and want to cancel the MovePrevious
event if needed. No matter what I try after my Sub runs it calls the
MovePrevious event. This is also true for all of the binding navigator
toolbar buttons (delete, addnew, etc..). There is no e.handled and
neither exit sub nor CancelCurrentEdit seem to work. Can this even be
done?
 
Ad

Advertisements

V

VJ

can you show some code structure.. of where your error occurs.. or what is
wrong..

VJ
 
Ad

Advertisements

M

mr_doles

Here is the delete confirm:
Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
BindingNavigatorDeleteItem.Click
Dim confirm As DialogResult
confirm = MessageBox.Show("Are you sure you want to delete this
record?", "Confirm Delete", MessageBoxButtons.YesNo,
MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)

If confirm = Windows.Forms.DialogResult.No Then
CANCEL THE DELETE
ElseIf confirm = Windows.Forms.DialogResult.Yes Then
Me.Validate()
Me.ExpensesBindingSource.EndEdit()

Me.ExpensesTableAdapter.Update(Me.AmazonExpensesDataSet.expenses)
End If
End Sub

No matter what I put in for DialogResult.No the delete still occurs.
Granted it is not committed to the DB until the save is clicked but the
row is deleted from the table.

Here is the move to pervious record. I took out all code except the
cancel edit.
Private Sub MoveToNewRow(ByVal sender As Object, ByVal e As
System.EventArgs) Handles BindingNavigatorMovePreviousItem.Click

Me.ExpensesBindingSource.CurrencyManager.CancelCurrentEdit()
CANCEL MOVE TO PREVIOUS RECORD
End Sub

After the CancelCurrentEdit is called it still moves to the previous
record. How can I make it not do that?
 

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

Top