我目前正在将我的项目从列表视图更改为数据网格视图,并遇到另一个问题"当我尝试删除以x string开头的行时。
For Each itm As DataGridViewRow In DataGridView1.Rows
If Not itm.Cells(0).Value.StartsWith(myValue) Then
DataGridView1.Rows.Remove(itm)
End If
Next
所以是的,我得出的结论是,它以某种方式弄乱了索引或foreach,因为在删除了一行之后,它会跳过占用其他索引/位置的下一行,如果这样做有意义的话。