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

时间:2016-04-25 15:55:03

标签: vb.net events datagridview click

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

3 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:0)

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

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

End Sub

答案 2 :(得分: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