datagridview 中特定单元格的单击事件 vb.net
Click event for specific cell in datagridview vb.net
我在 datagridview 中有一个单元格,它位于第 8 行第 2 列那个单元格和那个单元格只有在单击时我想显示为另存为对话框但我实际上可以获得特定单元格发生的单击事件如何我要在 vb.net 中执行此操作吗?
在你的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
Private Sub DataGridView1_CellClick(sender As Object, e As `DataGridViewCellEventArgs`) Handles DataGridView1.CellClick
''Code HERE............
End Sub
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
我在 datagridview 中有一个单元格,它位于第 8 行第 2 列那个单元格和那个单元格只有在单击时我想显示为另存为对话框但我实际上可以获得特定单元格发生的单击事件如何我要在 vb.net 中执行此操作吗?
在你的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
Private Sub DataGridView1_CellClick(sender As Object, e As `DataGridViewCellEventArgs`) Handles DataGridView1.CellClick
''Code HERE............
End Sub
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