我正在我的系统中进行搜索,但它说:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
我只能输入一个数字,在我擦除或输入另一个数字后它会弹出错误。
这是我的代码:
Try
For row As Integer = 0 To dgv_room.Rows.Count
If dgv_room.Rows(row).Cells(0).Value.ToString.Substring(0, tbx_search.Text.Length) = tbx_search.Text Then
dgv_room.Rows(row).Selected = True
Exit For
End If
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try