From: John on 29 Sep 2005 23:33 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
From: Ken Tucker [MVP] on 30 Sep 2005 06:47 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" <John(a)nospam.infovis.co.uk> wrote in message news:%235Km6%23WxFHA.3756(a)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 > >
From: John on 30 Sep 2005 14:36 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]" <vb2ae(a)bellsouth.net> wrote in message news:e5a0kxaxFHA.720(a)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" <John(a)nospam.infovis.co.uk> wrote in message > news:%235Km6%23WxFHA.3756(a)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 >> >> > >
From: Ken Tucker [MVP] on 30 Sep 2005 18:50 John, Are you binding to a dataset? Ken ---------------- "John" <John(a)nospam.infovis.co.uk> wrote in message news:e59Sn3exFHA.3720(a)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]" <vb2ae(a)bellsouth.net> wrote in message > news:e5a0kxaxFHA.720(a)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" <John(a)nospam.infovis.co.uk> wrote in message >> news:%235Km6%23WxFHA.3756(a)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 >>> >>> >> >> > >
From: Ken Tucker [MVP] on 30 Sep 2005 19:08
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" <John(a)nospam.infovis.co.uk> wrote in message news:e59Sn3exFHA.3720(a)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]" <vb2ae(a)bellsouth.net> wrote in message > news:e5a0kxaxFHA.720(a)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" <John(a)nospam.infovis.co.uk> wrote in message >> news:%235Km6%23WxFHA.3756(a)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 >>> >>> >> >> > > |