我有一个ultrawridrid,我可以选择行上,并需要能够删除突出显示的行。目前,它调用我编写的数据库SQL查询,但不是删除所选行中的记录,而是删除顶行中的记录。任何人都可以解释为什么?UltraWinGrid删除顶部记录而不是所选的一个
Private Sub btnDeleteIncident_Click(sender As Object, e As EventArgs) Handles btnDeleteIncident.Click
Try
Dim rowValue = ugHistory.Selected.Rows
Dim rowToDelete = ugHistory.Rows(0).Cells(0).Value.ToString
Dim removeIncident As MsgBoxResult
removeIncident = MsgBox("Are you sure you wish to delete this incident?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirm")
If removeIncident = MsgBoxResult.Yes Then
Database.deleteIncident(rowToDelete)
txtClientSave.Text = ""
rtbProblem.Text = ""
rtbSolution.Text = ""
dtpStart.Value = Date.Today
dtpEnd.Value = Date.Today
dtpStartTime.Value = DateTime.Now
dtpEndTime.Value = DateTime.Now
cboxSolved.Checked = False
btnUpdate.Hide()
btnSave.Show()
ElseIf removeIncident = MsgBoxResult.No Then
loadIncidents()
End If
Catch Ex As Exception
MsgBox("No incidents to delete")
End Try
loadIncidents()
End Sub
数据库SQL查询;
Public Shared Sub deleteIncident(ByVal supportID As Integer)
Connect()
Dim Dc As New OleDbCommand
Dc.Connection = Con
Dc.CommandText = "DELETE * FROM tblIncidents WHERE([supportID] = " & supportID & ")"
Dc.ExecuteNonQuery()
Disconnect()
End Sub
因为你设置rowToDelete到电网的第一行不选择 – Steve
行@Steve我该如何改变呢?我尝试过使用e.Selected.Rows,但是这也不起作用 – David