If dgvData.RowCount = 0 Or dgvData.CurrentRow Is Nothing Then Exit Sub
Dim Url As String = dgvData.Item(1, dgvData.CurrentRow.Index).Value
'// ถามยืนยันการลบข้อมูล
Dim Result As Byte = MessageBox.Show("Are you sure you want to delete the data?" & vbCrLf & "URL/Name: " & Url, "Confirm Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
If Result = DialogResult.Yes Then
'// Receive Primary Key value to confirm the deletion.
'// Function to handle the KeyPress event for TextBox controls.
Private Sub TextBox_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtLogin.KeyPress, txtPassword.KeyPress, txtUrl.KeyPress, txtEmail.KeyPress, txtPhone.KeyPress
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True '// Prevent the Enter key from adding a new line in the TextBox.
SendKeys.Send("{TAB}") '// Send the TAB key to move to the next control.
End If
End Sub
Private Sub dtpDateModified_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles dtpDateModified.KeyDown
If e.KeyCode = Keys.Enter Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Private Sub frmPassCodeBook_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
Me.Dispose()
GC.SuppressFinalize(Me)
End
End Sub
Private Sub itemExit_Click(sender As System.Object, e As System.EventArgs) Handles itemExit.Click
Me.Close()
End Sub
End Class
โค้ดในส่วนของการจัดการฐานข้อมูล (modDataBase.vb)
โค้ด:
Imports System.Data.OleDb
Module modDataBase
Dim ConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & MyPath(Application.StartupPath) & "\PassCodeBook.accdb;"