Issue with Index was out of range. Must be non-negative and less than the size of the collection

109 Views Asked by At

enter image description here

Please help me to solve this error as I tried in more than one way When I try to change in cell number 5, the error appears, but the error does not appear if I try to change in any other cell

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For item As Integer = 0 To Employee_Shift_DetailDataGridView.RowCount - 1
           
            Employee_Shift_DetailDataGridView.Rows(item).Cells(5).Value = "001"
            
        Next
    End Sub

Thanks.

I tried to change the selection mode

0

There are 0 best solutions below