Solved

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

Posted on 2009-07-10
2
315 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
Comment Utility
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
Comment Utility
Excellent!  Thanks for that very full explanation.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now