By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,692 Members | 1,330 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,692 IT Pros & Developers. It's quick & easy.

Delete warning with bindingnavigator

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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
----------------
"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
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

Nov 21 '05 #2

P: n/a
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

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:e5*************@TK2MSFTNGP15.phx.gbl...
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
----------------
"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
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


Nov 21 '05 #3

P: n/a
John,

Are you binding to a dataset?

Ken
----------------
"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:e5**************@TK2MSFTNGP11.phx.gbl...
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

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:e5*************@TK2MSFTNGP15.phx.gbl...
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
----------------
"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
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



Nov 21 '05 #4

P: n/a
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

-------------------------

"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:e5**************@TK2MSFTNGP11.phx.gbl...
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

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:e5*************@TK2MSFTNGP15.phx.gbl...
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
----------------
"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
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



Nov 21 '05 #5

P: n/a
Yes. Re-read your post and I think I am OK now.

Thanks

Regards

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:ea**************@TK2MSFTNGP12.phx.gbl...
John,

Are you binding to a dataset?

Ken
----------------
"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:e5**************@TK2MSFTNGP11.phx.gbl...
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

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:e5*************@TK2MSFTNGP15.phx.gbl...
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
----------------
"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
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



Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.