following is the issue.
I want to get the row index and column index of the deleted row of datagridview for some calculations and updations.but the error i keep getting is object reference not set to an instance of an object. i have written the code in the rows removed event of the data gridview.heres the code.
Try
delflag = True
Dim quant As Integer
If dgsalesitem.CurrentRow.Cells(0).Value = 0 Then
quant = dgsalesitem.CurrentRow.Cells(1).Value
Else
quant = dgsalesitem.CurrentRow.Cells(0).Value
End If
UpdateStock(dgsalesitem.CurrentRow.Cells(2).Value.ToString, dgsalesitem.CurrentRow.Cells(9).Value.ToString, dgsalesitem.CurrentRow.Cells(10).Value.ToString, quant, False)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
You could catch the
UserDeletingRow
event when user is about to delete the row:And if you want to get the
Row Index
of the row deleted, you could simply use: