필자는 ultrawingrid를 사용하여 행을 선택할 수 있으며 강조 표시된 행을 삭제할 수 있어야합니다. 현재 내가 작성한 데이터베이스 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
에 대한 검사를 추가하여 코드를 실행하기 전에 당신이없는 나는이 어떻게 변경합니까 @ 스티브 선택한 행 – Steve
에 그리드의 첫 번째 행에 rowToDelete 설정되어 있기 때문에? 나는 e.Selected.Rows를 사용하여 시도했지만 어느 쪽도 작동하지 않았다. – David