السلام عليكم اساتذتي و اصدقاء المنتدى
مشكلتي في زر التالي مع الداتاجريدفيور يظهر معي هذه الرسالة : System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index'
مشكلتي في زر التالي مع الداتاجريدفيور يظهر معي هذه الرسالة : System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index'
كود :
Private Sub Buttonnext_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 = True
End Sub
(31-01-24, 04:53 PM)annagui كتب : السلام عليكم اساتذتي و اصدقاء المنتدىوجدت الحل و للاستفادة هذا الكود شغال 100%
مشكلتي في زر التالي مع الداتاجريدفيور يظهر معي هذه الرسالة : System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index'
كود :
Private Sub Buttonnext_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 = True
End Sub
كود :
Dim nextRow As Integer = dataGridView1.CurrentRow.Index + 1
If nextRow < dataGridView1.Rows.Count Then
Me.dataGridView1.CurrentCell = dataGridView1.Rows(nextRow).Cells(dataGridView1.CurrentCell.ColumnIndex)
End If