Delete warning with bindingnavigator

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    Delete warning with bindingnavigator

    Hi

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

    Thanks

    Regards


  • Ken Tucker [MVP]

    #2
    Re: Delete warning with bindingnavigato r

    Hi,

    I wish the bindingnavigato rdelete_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 AdventureWorksD ataSet.Tables(0 ).RowDeleted, AddressOf
    Row_Deleting


    Private Shared Sub Row_Deleting(By Val sender As Object, _
    ByVal e As DataRowChangeEv entArgs)
    If MessageBox.Show ("Are you sure?", "", MessageBoxButto ns.YesNo) =
    Windows.Forms.D ialogResult.No Then
    e.Row.RejectCha nges()
    End If
    End Sub

    Ken
    ----------------
    "John" <John@nospam.in fovis.co.uk> wrote in message
    news:%235Km6%23 WxFHA.3756@tk2m sftngp13.phx.gb l...[color=blue]
    > Hi
    >
    > When I press the delete button on the BindingNavigato r it deletes the
    > record without any warning. How can I add a warning dialog when the delete
    > button on the BindingNavigato r is pressed and before the record is
    > actually deleted?
    >
    > Thanks
    >
    > Regards
    >
    >[/color]


    Comment

    • John

      #3
      Re: Delete warning with bindingnavigato r

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

      Regards

      "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
      news:e5a0kxaxFH A.720@TK2MSFTNG P15.phx.gbl...[color=blue]
      > Hi,
      >
      > I wish the bindingnavigato rdelete_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 AdventureWorksD ataSet.Tables(0 ).RowDeleted, AddressOf
      > Row_Deleting
      >
      >
      > Private Shared Sub Row_Deleting(By Val sender As Object, _
      > ByVal e As DataRowChangeEv entArgs)
      > If MessageBox.Show ("Are you sure?", "", MessageBoxButto ns.YesNo) =
      > Windows.Forms.D ialogResult.No Then
      > e.Row.RejectCha nges()
      > End If
      > End Sub
      >
      > Ken
      > ----------------
      > "John" <John@nospam.in fovis.co.uk> wrote in message
      > news:%235Km6%23 WxFHA.3756@tk2m sftngp13.phx.gb l...[color=green]
      >> Hi
      >>
      >> When I press the delete button on the BindingNavigato r it deletes the
      >> record without any warning. How can I add a warning dialog when the
      >> delete button on the BindingNavigato r is pressed and before the record is
      >> actually deleted?
      >>
      >> Thanks
      >>
      >> Regards
      >>
      >>[/color]
      >
      >[/color]


      Comment

      • Ken Tucker [MVP]

        #4
        Re: Delete warning with bindingnavigato r

        John,

        Are you binding to a dataset?

        Ken
        ----------------
        "John" <John@nospam.in fovis.co.uk> wrote in message
        news:e59Sn3exFH A.3720@TK2MSFTN GP11.phx.gbl...[color=blue]
        > Doesn't seem to work for me. The msgbox never appears. I am using the
        > BindingNavigato r. Do I need to change anything at that end?
        >
        > Regards
        >
        > "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
        > news:e5a0kxaxFH A.720@TK2MSFTNG P15.phx.gbl...[color=green]
        >> Hi,
        >>
        >> I wish the bindingnavigato rdelete_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 AdventureWorksD ataSet.Tables(0 ).RowDeleted, AddressOf
        >> Row_Deleting
        >>
        >>
        >> Private Shared Sub Row_Deleting(By Val sender As Object, _
        >> ByVal e As DataRowChangeEv entArgs)
        >> If MessageBox.Show ("Are you sure?", "", MessageBoxButto ns.YesNo) =
        >> Windows.Forms.D ialogResult.No Then
        >> e.Row.RejectCha nges()
        >> End If
        >> End Sub
        >>
        >> Ken
        >> ----------------
        >> "John" <John@nospam.in fovis.co.uk> wrote in message
        >> news:%235Km6%23 WxFHA.3756@tk2m sftngp13.phx.gb l...[color=darkred]
        >>> Hi
        >>>
        >>> When I press the delete button on the BindingNavigato r it deletes the
        >>> record without any warning. How can I add a warning dialog when the
        >>> delete button on the BindingNavigato r is pressed and before the record
        >>> is actually deleted?
        >>>
        >>> Thanks
        >>>
        >>> Regards
        >>>
        >>>[/color]
        >>
        >>[/color]
        >
        >[/color]


        Comment

        • Ken Tucker [MVP]

          #5
          Re: Delete warning with bindingnavigato r

          Hi,

          Try this instead. In the designer set the bindingnavigato rs
          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
          BindingNavigato rDeleteItem_Cli ck event open. Add the code below to control
          the delete.

          Private Sub BindingNavigato rDeleteItem_Cli ck(ByVal sender As
          System.Object, ByVal e As System.EventArg s) Handles
          BindingNavigato rDeleteItem.Cli ck
          If MessageBox.Show ("Are you sure?", "", MessageBoxButto ns.YesNo) =
          Windows.Forms.D ialogResult.Yes Then
          ContactBindingS ource.RemoveCur rent()
          End If
          End Sub




          Ken

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

          "John" <John@nospam.in fovis.co.uk> wrote in message
          news:e59Sn3exFH A.3720@TK2MSFTN GP11.phx.gbl...[color=blue]
          > Doesn't seem to work for me. The msgbox never appears. I am using the
          > BindingNavigato r. Do I need to change anything at that end?
          >
          > Regards
          >
          > "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
          > news:e5a0kxaxFH A.720@TK2MSFTNG P15.phx.gbl...[color=green]
          >> Hi,
          >>
          >> I wish the bindingnavigato rdelete_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 AdventureWorksD ataSet.Tables(0 ).RowDeleted, AddressOf
          >> Row_Deleting
          >>
          >>
          >> Private Shared Sub Row_Deleting(By Val sender As Object, _
          >> ByVal e As DataRowChangeEv entArgs)
          >> If MessageBox.Show ("Are you sure?", "", MessageBoxButto ns.YesNo) =
          >> Windows.Forms.D ialogResult.No Then
          >> e.Row.RejectCha nges()
          >> End If
          >> End Sub
          >>
          >> Ken
          >> ----------------
          >> "John" <John@nospam.in fovis.co.uk> wrote in message
          >> news:%235Km6%23 WxFHA.3756@tk2m sftngp13.phx.gb l...[color=darkred]
          >>> Hi
          >>>
          >>> When I press the delete button on the BindingNavigato r it deletes the
          >>> record without any warning. How can I add a warning dialog when the
          >>> delete button on the BindingNavigato r is pressed and before the record
          >>> is actually deleted?
          >>>
          >>> Thanks
          >>>
          >>> Regards
          >>>
          >>>[/color]
          >>
          >>[/color]
          >
          >[/color]


          Comment

          • John

            #6
            Re: Delete warning with bindingnavigato r

            Yes. Re-read your post and I think I am OK now.

            Thanks

            Regards

            "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
            news:ea48bFhxFH A.3892@TK2MSFTN GP12.phx.gbl...[color=blue]
            > John,
            >
            > Are you binding to a dataset?
            >
            > Ken
            > ----------------
            > "John" <John@nospam.in fovis.co.uk> wrote in message
            > news:e59Sn3exFH A.3720@TK2MSFTN GP11.phx.gbl...[color=green]
            >> Doesn't seem to work for me. The msgbox never appears. I am using the
            >> BindingNavigato r. Do I need to change anything at that end?
            >>
            >> Regards
            >>
            >> "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
            >> news:e5a0kxaxFH A.720@TK2MSFTNG P15.phx.gbl...[color=darkred]
            >>> Hi,
            >>>
            >>> I wish the bindingnavigato rdelete_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 AdventureWorksD ataSet.Tables(0 ).RowDeleted, AddressOf
            >>> Row_Deleting
            >>>
            >>>
            >>> Private Shared Sub Row_Deleting(By Val sender As Object, _
            >>> ByVal e As DataRowChangeEv entArgs)
            >>> If MessageBox.Show ("Are you sure?", "", MessageBoxButto ns.YesNo)
            >>> = Windows.Forms.D ialogResult.No Then
            >>> e.Row.RejectCha nges()
            >>> End If
            >>> End Sub
            >>>
            >>> Ken
            >>> ----------------
            >>> "John" <John@nospam.in fovis.co.uk> wrote in message
            >>> news:%235Km6%23 WxFHA.3756@tk2m sftngp13.phx.gb l...
            >>>> Hi
            >>>>
            >>>> When I press the delete button on the BindingNavigato r it deletes the
            >>>> record without any warning. How can I add a warning dialog when the
            >>>> delete button on the BindingNavigato r is pressed and before the record
            >>>> is actually deleted?
            >>>>
            >>>> Thanks
            >>>>
            >>>> Regards
            >>>>
            >>>>
            >>>
            >>>[/color]
            >>
            >>[/color]
            >
            >[/color]


            Comment

            Working...