Gor510
Eccentric Innovator
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
400 XP
When you add a DataSet to your Windows Form a BindingNavigator is automatically created with navigation to your record and it also includes Delete and Add button.
When you click the Delete button there is no confirmation if you want to cancel the operation. The solution to this is to set the DeleteItem to None. See screenshot below:
Here's the code in the Delete button under BindingNavigator:
When you click the Delete button there is no confirmation if you want to cancel the operation. The solution to this is to set the DeleteItem to None. See screenshot below:

Here's the code in the Delete button under BindingNavigator:
- Private
Sub
BindingNavigatorDeleteItem_Click(
ByVal
sender As
System.
Object
, ByVal
e As
System.
EventArgs
)
- If
MessageBox.
Show
(
"Are you sure you want to delete this record?"
, "Delete record"
, MessageBoxButtons.
YesNo
, MessageBoxIcon.
Exclamation
)
=
Windows.
Forms
.
DialogResult
.
Yes
Then
- Me
.
ProgramsBindingSource
.
RemoveCurrent
(
)
- Try
- Me
.
Validate
(
)
- Me
.
ProgramsBindingSource
.
EndEdit
(
)
- Me
.
TableAdapterManager
.
UpdateAll
(
Me
.
ProgramsDataSet
)
- MessageBox.
Show
(
"Record successfully deleted."
)
- Me
.
Close
(
)
- Catch
ex As
Exception
- MessageBox.
Show
(
ex.
Message
, "Error"
, MessageBoxButtons.
OK
, MessageBoxIcon.
Error
)
- End
Try
- End
If
- End
Sub