vb.net中textbox输入完后如何直接按回车
答案:5 悬赏:30 手机版
解决时间 2021-12-03 01:03
- 提问者网友:焚苦与心
- 2021-12-02 08:51
vb.net中textbox输入完后如何直接按回车
最佳答案
- 五星知识达人网友:毛毛
- 2021-12-02 09:46
思路很简单:通过textbox的keypress事件来捕获键盘输入,输入输入的是回车键,则调用Button_click事件
代码如下:
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = 13 Then
call Button1_Click()
end if
End Sub
代码如下:
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = 13 Then
call Button1_Click()
end if
End Sub
全部回答
- 1楼网友:摆渡翁
- 2021-12-02 13:22
KeyCode = 13 把13改成对应的vbKeyReturn
- 2楼网友:一袍清酒付
- 2021-12-02 12:19
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
F()
End Sub
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Return Then
F()
End If
End Sub
Private Sub F()
'
'你要实现的功能
'
End Sub
F()
End Sub
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Return Then
F()
End If
End Sub
Private Sub F()
'
'你要实现的功能
'
End Sub
- 3楼网友:山君与见山
- 2021-12-02 11:45
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Command1_Click
End If
End Sub
If KeyCode = 13 Then
Command1_Click
End If
End Sub
- 4楼网友:山君与见山
- 2021-12-02 11:04
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = 13 Then Button1.PerformClick()
End Sub
If e.KeyCode = 13 Then Button1.PerformClick()
End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯