[2005] Delete warning with bindingnavigator problem
Delete warning with bindingnavigator
When i press the delete button it comes up with prompt do i want to delete but if i click no it deletes anyway here is my code
vb.net Code:
Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click
''Delete current record after confirming.
'Dim deleteDialogResult As DialogResult
'Dim test As New System.ComponentModel.CancelEventArgs
'With Me
' If .BindingNavigatorDeleteItem.Text = "&Delete" Then
' deleteDialogResult = MessageBox.Show("Delete this record?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
' If deleteDialogResult = Windows.Forms.DialogResult.No Then
'
' MessageBox.Show("No Deletion Screen will close", "No Deletion", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
' 'Me.Close()
' e.EventsArgs.RejectChanges()
' End If
' End If
'End With
end sub
Re: [2005] Delete warning with bindingnavigator problem
Why is everything commented out?
Re: [2005] Delete warning with bindingnavigator problem
vb.net Code:
Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click
'Delete current record after confirming.
Dim deleteDialogResult As DialogResult
'Dim test As New System.ComponentModel.CancelEventArgs
With Me
If .BindingNavigatorDeleteItem.Text = "&Delete" Then
deleteDialogResult = MessageBox.Show("Delete this record?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If deleteDialogResult = Windows.Forms.DialogResult.No Then
MessageBox.Show("No Deletion Screen will close", "No Deletion", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
'Me.Close()
End If
End If
End With
End Sub
sorry about that i am working right tryin to figure it out
Re: [2005] Delete warning with bindingnavigator problem
I added [highlight=vb.net]your code goes in here[/highlight] tags to your post. When posting code, if you use these, it will be much easier to read. :)
I don't see any code doing any deleting. Just asking the question. Did that get removed somehow?
Re: [2005] Delete warning with bindingnavigator problem
well it generates itself from when i added the database to the form it gave me the bindingnavigation tools add delete and save when i click add it just add it on its own when i click delete it deletes i just put the prompt in askin if you want to delete or not and im tryin to cancel keep it from deleting
Re: [2005] Delete warning with bindingnavigator problem
have you tried stepping through your code to see what is going on?
Re: [2005] Delete warning with bindingnavigator problem
i tried stepping through it i need like a code to stop the process
Re: [2005] Delete warning with bindingnavigator problem
so at which line does it get stuck on?
Re: [2005] Delete warning with bindingnavigator problem
it really not getting stuck on no line it just going through the process it pops up the message box click yes or no i click no it stills delete the only way it doesnt delete it is if i have me.close but i dont want it to close the form
Re: [2005] Delete warning with bindingnavigator problem
vb Code:
Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click
If Me.BindingNavigatorDeleteItem.Text = "&Delete" Then
If MessageBox.Show("Delete this record?", _
"Confirm Delete", _
MessageBoxButtons.YesNo, _
MessageBoxIcon.Question) = Windows.Forms.DialogResult.No Then
'if no, do something
Else
'If yes, do something else
End If
End If
End Sub