Click event for specific cell in datagridview vb.n

2019-08-13 18:25发布

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?

3条回答
Luminary・发光体
2楼-- · 2019-08-13 18:37

In you dataGridView Event "DataGridView1_CellClick" add this code :

  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
查看更多
疯言疯语
3楼-- · 2019-08-13 18:37
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
查看更多
倾城 Initia
4楼-- · 2019-08-13 18:42
 Private Sub DataGridView1_CellClick(sender As Object, e As `DataGridViewCellEventArgs`) Handles DataGridView1.CellClick

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

End Sub
查看更多
登录 后发表回答