站长资源网络编程

VB.NET 中删除DataGridView中所选行的小例子

整理:jimmy2026/8/4浏览2
简介复制代码 代码如下:For Each r As DataGridViewRow In DataGridView1.SelectedRows If Not r.IsNewRow Then DataGridView1.Rows.Remove(r) End IfNext其实就是一
复制代码 代码如下:
For Each r As DataGridViewRow In DataGridView1.SelectedRows
    If Not r.IsNewRow Then
        DataGridView1.Rows.Remove(r)
    End If
Next

其实就是一个IsNewRow属性,判断是不是为新选中的行,如果不是,remove!