Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CurrentCellChanged

Status
Not open for further replies.

allanmc10

Programmer
Feb 23, 2006
39
GB
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top