为每个混乱索引删除datagridview中的行,以便跳过行

时间:2017-05-09 16:20:47

标签: vb.net datagridview foreach

我目前正在将我的项目从列表视图更改为数据网格视图,并遇到另一个问题"当我尝试删除以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,因为在删除了一行之后,它会跳过占用其他索引/位置的下一行,如果这样做有意义的话。

0 个答案:

没有答案