You could catch the UserDeletingRow
event when user is about to delete the row:
Private Sub dgsalesitem_UserDeletingRow(sender As Object, e As System.Windows.Forms.DataGridViewRowCancelEventArgs) Handles dgsalesitem.UserDeletingRow
Try
delflag = True
Dim quant As Integer
If e.Row.Cells(0).Value = 0 Then
quant = e.Row.Cells(1).Value
Else
quant = e.Row.Cells(0).Value
End If
UpdateStock(e.Row.Cells(2).Value.ToString, e.Row.Cells(9).Value.ToString, e.Row.Cells(10).Value.ToString, quant, False)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
And if you want to get the Row Index
of the row deleted, you could simply use:
e.Row.Index