当我的标签有焦点且有人点击“回车”时,我正试图让这个子执行。这是我到目前为止的代码......
Private Sub AssignOwnersLabel_Click() Handles AssignOwnersLabel.Click
Dim repository As OwnerRepositorySvc.OwnerRepositoryClient = Nothing
For Each programRow As DataGridViewRow In ProgramOwnerFill.SelectedRows
programRow.Cells(0).Value = AssignOwnersTXTBox.Text
Next
repository = OpenRepository()
repository.SaveOwners(_ds)
_ds.AcceptChanges()
CloseRepository(repository)
Dim dataview As DataView = _ds.ProgramOwners.DefaultView
dataview.Sort = _ds.ProgramOwners.EmployeeIDColumn.ColumnName
Me.ProgramOwnersBindingSource.DataSource = dataview
End Sub
我认为要让它工作,我需要用“keychar”做一些事情,但我不确定那会是什么样子。谢谢你的帮助!
答案 0 :(得分:0)
要确定用户是否按下了回车键,请执行以下操作:
Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
If e.KeyCode = Keys.Enter Then
' Put logic here for when the user pressed enter
End if
End Sub
注意:有几种关键类型的事件,例如KeyPress
,KeyDown
和KeyUp
。