2014-01-21 111 views
0

如何檢查我是否點擊了數據網格視圖中的數據? enter image description here
我已經試過dgv_click_mouseClick_cellcontentClicked檢查我是否點擊了datagridview行

btnEdit.Enabled = true 
btnDelete.Enabled = true 

沒有任何反應。
如果用戶點擊任一數據行,我希望它們被啓用。

回答

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