total in datagridview gives back 0

  • Thread starter Thread starter TG
  • Start date Start date
T

TG

Hi!

I have a datagridview and I want to sum one of the columns. (column 5)

When I run the following it gives me 0 instead of 10106 which is the
total of those rows.

Any ideas as to what I am doing wrong?

For i As Integer = 5 To 5
' loop through columns which require
calculating sum
Dim myTotalSum As Integer
For row As Integer = 10 To
DataGridView1.Rows.Count - 1
myTotalSum +=
Convert.ToInt16(DataGridView1(i, row).Value)
Next
DataGridView1(i, DataGridView1.Rows.Count -
1).Value = myTotalSum.ToString()
Next


Thank you!


Tammy
 
nevermind i fixed it myself.

I was starting at the wrong point

For row As Integer = 10 To


is supposed to be


For row As Integer = 0 To


Thanks to myself for the help :-)))))))
 
Back
Top