I have a datagridview that contains around 21000 rows, it has the following columns "Ref","Bestandsart" and an other 20 columns each one contains a stock value in a specific week, each week a new column will be added automatically.
the issue is that some value in "Ref" are repeated but the don't necessary have the same stock values, so what i wanted to do is to go throw each row(j) and if i find a "Ref" in rows(j+1 to dg.rowcount-1) i take the stock values of that row and add it to the stock values of row(j) and remove the duplicated "Ref".
here is the code :
Dim a = datagridview1.RowCount
Dim s(t2 - t1)
do until index >=a
If Not datagridview1.Rows(index).Cells("ref").Value.Equals(0) Then
For i = 0 To t2 - t1
s(i) = datagridview1.Rows(index).Cells("KW" + Convert.ToString(t1 + i)).Value
Next
For t = index + 1 To datagridview1.RowCount - 1
If datagridview1.Rows(index).Cells("Ref").Value.Equals(datagridview1.Rows(t).Cells("Ref").Value) And datagridview1.Rows(index).Cells("Bestandsart").Value.Equals(datagridview1.Rows(t).Cells("Bestandsart").Value) Then
For i = 0 To t2 - t1
s(i) = s(i) + datagridview1.Rows(t).Cells("KW" + Convert.ToString(t1 + i)).Value
Next
End If
Next
For i = 0 To t2 - t1
datagridview1.Rows(index).Cells("KW" + Convert.ToString(t1 + i)).Value = s(i)
Next
For t = index + 1 To datagridview1.RowCount - 1
If datagridview1.Rows(index).Cells("ref").Value.Equals(datagridview1.Rows(t).Cells("Ref").Value) And datagridview1.Rows(index).Cells("Bestandsart").Value.Equals(datagridview1.Rows(t).Cells("Bestandsart").Value) Then
datagridview1.Rows(t).Cells("ref").Value = 0
datagridview1.Rows(t).Cells("Bestandsart").Value = 0
End If
Next
BackgroundWorker1.ReportProgress((index + 1) * 100 / a)
index = index + 1
Else
BackgroundWorker1.ReportProgress((index + 1) * 100 / a)
index = index + 1
End If
loop
t1 is the 1st week and t2 is the last.
the problem is that i get an out of memory exception once i reach the 10000th row or so.
any ideas on how to solve this issue.
Thank you in advance.