Solved

VB 2008  - How to avoid (and commit) a deletion; DataGridView

Posted on 2009-07-10
2
333 Views
Last Modified: 2012-05-07
My concern is with activating the Deletion Icon on the BindingNavigator.  I want the user to confirm that the deletion should go forward after clicking on the Delete Icon.  If the user says NO, then there does not appear to be any way to prevent the deletion in code.

So the only way I can see is to set the BindingNavigator.DeleteItem to (none).  However, if the user desires to let the deletion occur, what code will accomplish that for a single selected record in the DataGridView?  (MultiSelect = False in this app.)
0
Comment
Question by:ljcor
2 Comments
 
LVL 12

Accepted Solution

by:
wht1986 earned 500 total points
ID: 24828802
The BindingNavigator has a property called 'DeleteItem'.
Change this property from 'BindingNavigatorDeleteItem' to '(none)'.
You can then delete the item (after confirmation) by using the BindingSource.RemoveCurrent method.


 Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click
        If MessageBox.Show("Do you really want to delete?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = Windows.Forms.DialogResult.Yes Then
            YourBindingSource.RemoveCurrent()
        End If
    End Sub
0
 

Author Closing Comment

by:ljcor
ID: 31602334
Excellent!  Thanks for that very full explanation.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question