have set up a datagridview in 2005 with the event (CurrentCellChanged) to perform calculations.
i am updating through stored procedures in SQLServer 2000.
If the datagridview has 2 rows in then it updates no problem but if the datagridview has 3 rows in it the program crashes out and tells me i need an obstance of an object on index 2
i think it has something to do with currentrow.index.
here is the code for CurrentCellChanged event
Private Sub dgSRLevel_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgSRLevel.CurrentCellChanged
If dgSRLevel.CurrentRow.Index >= 0 Then
If IsDBNull(dgSRLevel.Item(6, dgSRLevel.CurrentRow.Index()).FormattedValue) = False And IsDBNull(dgSRLevel.Item(8, dgSRLevel.CurrentRow.Index()).FormattedValue) Then
dgSRLevel.Item(9, dgSRLevel.CurrentRow.Index()).Value = CStr(CDec(dgSRLevel.Item(6, dgSRLevel.CurrentRow.Index()).FormattedValue) * CDec(dgSRLevel.Item(8, dgSRLevel.CurrentRow.Index()).FormattedValue))
End If
If IsDBNull(dgSRLevel.Item(7, dgSRLevel.CurrentRow.Index()).Value) = False And IsDBNull(dgSRLevel.Item(8, dgSRLevel.CurrentRow.Index()).Value) = False Then
dgSRLevel.Item(10, dgSRLevel.CurrentRow.Index()).Value = CStr(CDec(dgSRLevel.Item(7, dgSRLevel.CurrentRow.Index()).FormattedValue) * CDec(dgSRLevel.Item(8, dgSRLevel.CurrentRow.Index()).FormattedValue))
End If
End If
End Sub
any help would be appreciated
regards
big al everbodies pal
i am updating through stored procedures in SQLServer 2000.
If the datagridview has 2 rows in then it updates no problem but if the datagridview has 3 rows in it the program crashes out and tells me i need an obstance of an object on index 2
i think it has something to do with currentrow.index.
here is the code for CurrentCellChanged event
Private Sub dgSRLevel_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgSRLevel.CurrentCellChanged
If dgSRLevel.CurrentRow.Index >= 0 Then
If IsDBNull(dgSRLevel.Item(6, dgSRLevel.CurrentRow.Index()).FormattedValue) = False And IsDBNull(dgSRLevel.Item(8, dgSRLevel.CurrentRow.Index()).FormattedValue) Then
dgSRLevel.Item(9, dgSRLevel.CurrentRow.Index()).Value = CStr(CDec(dgSRLevel.Item(6, dgSRLevel.CurrentRow.Index()).FormattedValue) * CDec(dgSRLevel.Item(8, dgSRLevel.CurrentRow.Index()).FormattedValue))
End If
If IsDBNull(dgSRLevel.Item(7, dgSRLevel.CurrentRow.Index()).Value) = False And IsDBNull(dgSRLevel.Item(8, dgSRLevel.CurrentRow.Index()).Value) = False Then
dgSRLevel.Item(10, dgSRLevel.CurrentRow.Index()).Value = CStr(CDec(dgSRLevel.Item(7, dgSRLevel.CurrentRow.Index()).FormattedValue) * CDec(dgSRLevel.Item(8, dgSRLevel.CurrentRow.Index()).FormattedValue))
End If
End If
End Sub
any help would be appreciated
regards
big al everbodies pal