Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'LoginSystemDataSet.Administrator' table. You can move, or remove it, as needed.
Me.AdministratorTableAdapter.Fill(Me.LoginSystemDataSet.Administrator)
With lstDetails.Columns
.Add("Username", 200, HorizontalAlignment.Center)
.Add("Password", 300, HorizontalAlignment.Center)
.Add("Email", 300, HorizontalAlignment.Center)
End With
End Sub
Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click
If lstDetails.SelectedItems.Count = 1 Then
Dim Button = MessageBox.Show("Are you sure you want to delete this Data?", _
"Message", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
If Button = Windows.Forms.DialogResult.Yes Then
Dim dt As New LoginSystemDataSet.AdministratorDataTable
Dim ds As New LoginSystemDataSetTableAdapters.AdministratorTableAdapter
AdministratorBindingSource.List.Remove(lstDetails.SelectedItems.Item(0))
AdministratorTableAdapter.Update(LoginSystemDataSet.Administrator)
lstDetails.Items.Remove(lstDetails.SelectedItems.Item(0))
'Dim da As New DataTable
'AdministratorTableAdapter.DeleteQuery(lstDetails.SelectedItems.Item(0).Text)
'lstDetails.Items.Remove(lstDetails.SelectedItems.Item(0))
' AdministratorTableAdapter.Update(da)
End If
Else
AdministratorBindingSource.CancelEdit()
MsgBox("No items is selected in the list provided", MsgBoxStyle.Critical)
End If
End Sub
Private Sub AdministratorBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
Me.Validate()
Me.AdministratorBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.LoginSystemDataSet)
End Sub
我正在尝试通过单击列表视图中的项目来删除行,然后从数据库中的选定行中删除它。但它不起作用。