datagridview vb.net 中特定单元格的单击事件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36845456/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 19:50:39  来源:igfitidea点击:

Click event for specific cell in datagridview vb.net

vb.neteventsdatagridviewclick

提问by TM80

I have a cell in a datagridview its located at the 8th row 2nd column That cell and that cell only if clicked I want to show as save as dialoguebox but I can actually get a click event happening for a specific cell how do I do this in vb.net?

我在 datagridview 中有一个单元格,它位于第 8 行第 2 列该单元格和该单元格仅当单击时我想显示为另存为对话框但我实际上可以为特定单元格发生单击事件我该怎么做vb.net?

回答by Beldi Anouar

In you dataGridView Event "DataGridView1_CellClick" add this code :

在您的 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

回答by Rohit Hadiya

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

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

End Sub

回答by oncreatesoft

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