One quick question. I have a delete button and i want when the user press it to get a message "Are you sure you want to delete it?" and when he press yes, it will delete the record. when he press "no", do nothing.
Printable View
One quick question. I have a delete button and i want when the user press it to get a message "Are you sure you want to delete it?" and when he press yes, it will delete the record. when he press "no", do nothing.
What are you using for your database? This will give you the basis for handling the eval of deletion.
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If MessageBox.Show("Are you sure you want to delete?", "Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = DialogResult.Yes Then 'Delete record End If End Sub
Note that im usning the delete button on the tool bar
Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click
End Sub
mainly i need to know how i can say to the system to do nothing when the yes is pressed
Oh, ok but I assume then that your using 2005?
Then just presesnt the messagebox like I posted and when they select no, you usse the e.Handled = True to cancel out. I think there is the same argument as I am only running 2003 right now.
Yes, im using 2005. Nevertheless there is no e.handled = true. Is there another way to say "Do Nothing?"
There has to =be something similar in the EventArgs?
Nothing.......i tried everything. im sure that something should be there but im new in .net and not too familiar...any other ideas?
Not sure. Its hard without having it. :(
Have you tried a search in the help files or msdn online?
Just one reason why I like to code my db access instead of using bound controls. ;)
Maybe change the argument to your event to...
system.componentModel.cancelEventArgs
and use
e.cancel = true
return
it's what I use to get out of the onClosing event in a similar situation
You can't just change the type of the arguments for an event handler. Different events receive different argument types and its not up to you what they are.
I'm guessing that there is no facility to cancel the delete operation through the BindingNavigator. You may be able to handle the RowDeleted event of the underlying DataTable and then ask for confirmation there. If the user says No you could call RejectChanges on the row that was deleted and it will be magically undeleted.
You may create a custom item in the BindingNavigatorToolbar, and execute the BindingSource.RemoveCurrent when desired.
(Sorry my English :D )