Datagridview活动行集是不可选的?

时间:2013-11-14 23:36:38

标签: datagridview

Dim index As Integer = DataGridView1.Rows.Count - 1
For Each row As DataGridViewRow In DataGridView1.Rows
       'Do events..
        row.Cells(1).Value = "Loading.."
        row.ReadOnly = True
Next

对不起我的英语。 我的gridview编辑和删除已启用。我想要: 如果Cell值为“Loading ..”,则该行不会被用户选择或删除。 谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

OnEvent:UserDeletingRow你可以取消它:例子。

Private Sub DataGridView1_UserDeletingRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowCancelEventArgs) Handles DataGridView1.UserDeletingRow
        If (e.Row.Cells(1).Value = "loading") Then
            e.Cancel = True
        End If

End Sub