My problem is with the Next button. At the last rows, this message appears : System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index'
-
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
Dim i As Integer = DataGridView1.CurrentRow.Index + 1
If i < 0 Then i = 0
DataGridView1.CurrentCell = Me.DataGridView1.Rows(i).Cells(0)
DataGridView1.Rows(i).Selected = TrueEnd Sub
-
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
Dim i As Integer = DataGridView1.CurrentRow.Index + 1
If i < 0 Then i = 0
DataGridView1.CurrentCell = Me.DataGridView1.Rows(i).Cells(0)
DataGridView1.Rows(i).Selected = TrueEnd Sub
Look at the error message again. It is telling you that the value of your index variable is outside the range of rows in
DataGridView1
. Most likely because of the line below:Dim i As Integer = DataGridView1.CurrentRow.Index + 1
If you are currently at the last row then
"Index + 1"
will refer to a row that does not exist. -
Look at the error message again. It is telling you that the value of your index variable is outside the range of rows in
DataGridView1
. Most likely because of the line below:Dim i As Integer = DataGridView1.CurrentRow.Index + 1
If you are currently at the last row then
"Index + 1"
will refer to a row that does not exist. -
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
Dim i As Integer = DataGridView1.CurrentRow.Index + 1
If i < 0 Then i = 0
DataGridView1.CurrentCell = Me.DataGridView1.Rows(i).Cells(0)
DataGridView1.Rows(i).Selected = TrueEnd Sub
Yes, the litehold, of definitive approaches, does do concurrent programming, when SDLC, was exposition of CsE.