You are on page 1of 2

Adding code to the form buttons

Add new
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnAdd.Click

CustomersBindingSource.AddNew()
End Sub

Save
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnSave.Click

Try
CustomersBindingSource.EndEdit()
TableAdapterManager.UpdateAll(It4uDataSet)
MsgBox("Record Successfully saved")
Catch ex As Exception
MsgBox("Error occur, please recheck the fields and try again")
End Try

End Sub

Delete
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnDelete.Click

CustomersBindingSource.EndEdit()
TableAdapterManager.UpdateAll(It4uDataSet)
MsgBox("Record deleted")
End Sub
End Class
Exit/close
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Handles btnClose.Click

If MessageBox.Show("Are you sure you want to exit?", "Exit",


MessageBoxButtons.YesNo,
MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
frmMain.Show()

Me.Hide()
Else
Return
End If

End Sub

Move next
Private Sub btnNext_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnNext.Click

Customersbindingsource.MoveNext

End Sub

Move previous code


Private Sub btnPrevious_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnPrevious.Click

Customersbindingsource.MovePrevious
End Sub

You might also like