首先,我想潜在道歉,因为我是新的Visual Basic(自学),所以我的一些代码可能看起来很奇怪。Visual Basic - 输入执行DataGridView CellContentClick
我加载一个DataGridView的信息由SELECT语句填充,当我点击视图内的某个单元格时,它会加载一个新的表单,这很好。不过,我想知道是否有方法可以将点击更改为“ENTER”键。
我附上我的代码,希望这有助于。
预先感谢您
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.Enter Then ' not sure on code here
End Sub
Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
If Update_Detail.Visible = True Then Update_Detail.Close()
Dim istat As Object
If e.RowIndex > -1 Then istat = DataGridView1.Rows(e.RowIndex).Cells(0).Value
If e.ColumnIndex < 1 And e.RowIndex > -1 Then Update_Detail.TextBox1.Text = istat
If e.ColumnIndex < 1 And e.RowIndex > -1 Then Update_Detail.Show()
End Sub
而且我使用Visual Studio 2015 .Net框架4.5.2
如果你正在使用'vb.net'那么就没有必要还包括'VBA'标签。 – braX
谢谢 - 这已被删除。 – user3482471
网格上有一个Key_Down事件。你可以使用这个。 – SQLAndOtherStuffGuy