Solved

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

Posted on 2009-07-10
2
337 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sql server insert 13 46
ASP/VB email question 4 61
DataGridView / get bound table name? 8 36
VB.Net creating Contact in Outlook 1 51
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…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

756 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