2016-04-25 88 views
0

我在datagridview中有一個單元格,它位於第8行第2列單元格和那個單元格只有點擊時我想顯示爲另存爲dialogbox,但我實際上可以獲得一個點擊事件發生的具體細胞如何在vb.net中做到這一點?datagridview中特定單元格的點擊事件vb.net

回答

0

在你的dataGridView 「事件DataGridView1_CellClick」 添加以下代碼:

Private Sub DataGridView1_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick 

    If e.ColumnIndex = 2 And e.RowIndex = 8 Then 
     'Do any thing 

     MsgBox("yes" + DataGridView1.Item(e.ColumnIndex, e.RowIndex).Value.ToString()) 

    End If 
End Sub 
0
Private Sub DataGridView1_CellClick(sender As Object, e As `DataGridViewCellEventArgs`) Handles DataGridView1.CellClick 

''Code HERE............ 

End Sub 
0
Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView_pos.CellContentClick 
     Dim i As Integer 

     With DataGridView_pos 
      If e.RowIndex >= 0 Then 
       i = .CurrentRow.Index 

       txt_update_detail_id.Text = .Rows(i).Cells("id").Value.ToString 

      End If 
     End With 

    End Sub 
'txt_update_detail_id.Text Output value by id (Mysql database) 
'Is work 
相關問題