I have what should be a simple problem to fix.

I am trying to insert an initial line (0) into a datagridview (named params). The program will then read each cell in that row, pass them through a function and return values be placed into the next line (1). This will continue until one of the parameters reaches some set point.

The problem that I am having is that when I try to insert a new line, it appears above the initial one and not below it like I would like it to.

Here's my code so far:

Code:
  1. Private Sub HurricaneWinds_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.         Dim init_xrange() As Double = New Double() {0.0, 0.0, 0.0, 40.0, 0.0}
  3.  
  4.        
  5.         For i As Integer = 0 To 4
  6.             params(i, 0).Value = init_xrange(i)
  7.         Next
  8.  
  9.         Dim xx(4) As Double
  10.        
  11.  
  12.         For j As Integer = 1 To 10
  13.             Dim prange() As Double = New Double() {CDbl(DragCo.Text.Trim), CDbl(WindVelCoef.Text.Trim), CDbl(WindVelExp.Text.Trim), CDbl(Gravity.Text.Trim)}
  14.             Dim xrange() As Double = New Double() {CDbl(params(0, j - 1).Value), CDbl(params(1, j - 1).Value), CDbl(params(2, j - 1).Value), CDbl(params(3, j - 1).Value), CDbl(params(4, j - 1).Value)}
  15.             xx = rk4(CInt(NumTimesteps.Text.Trim), CDbl(TimeStep.Text.Trim), xrange, prange)
  16.            
  17.             Dim item As New DataGridViewRow
  18.             item.CreateCells(params)
  19.             With item
  20.                 .Cells(0).Value = xx(0)
  21.                 .Cells(1).Value = xx(1)
  22.                 .Cells(2).Value = xx(2)
  23.                 .Cells(3).Value = xx(3)
  24.                 .Cells(4).Value = xx(4)
  25.             End With
  26.             params.Rows.Add(item)
  27.            
  28.         Next
  29.  
  30.     End Sub

And a picture of the problem:

Name:  rows.JPG
Views: 1571
Size:  21.8 KB

Any suggestions?

Thanks