检查我是否单击了datagridview行

时间:2014-01-21 05:24:47

标签: .net vb.net datagridview

如何检查我是否在数据网格视图中点击了数据? enter image description here
我尝试过dgv_click_mouseClick_cellcontentClicked

btnEdit.Enabled = true
btnDelete.Enabled = true
没有任何反应。
如果用户点击任一数据行,我希望它们被启用。

1 个答案:

答案 0 :(得分:0)

您需要为.CellClick事件

创建处理程序
    Private Sub dgv_CellClick(sender AS Object, e As DataGridViewCellEventArgs) Handles dgv.CellClick
        'you can get cell's rowindex and columnindex where was clicked
        If e.RowIndex >= 0 AndAlso e.ColumnIndex >= 0 Then

            'here put your code based on the clicked cell

        End If
    End Sub