我有一个 ToolStripTextBox(它的名称是 SearchBox),我希望在用户键入内容并按下回车键后将它们带到一个 URL。我已经整理好 URL 部分,但我需要知道之后会发生什么
Handles SearchBox.{what?}
当用户按下“enter”时,我在智能感知弹出窗口中没有看到任何事件。
那么,换句话说,我该如何在用户按下 enter 后执行操作?
Private Sub ToolStripComboBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchBox.**?????**
Dim SearchString As String
SearchString = SearchBox.Text
Dim URL As String
URL = ("https://www.example.com/search.php?&q=" + SearchString)
Process.Start(URL)
End Sub
最佳答案
获取自:
eliminate the enter key after pressing it in the keyup event of a textbox
不准确,但有帮助。
Public Sub SearchBox_KeyPress(ByVal sender As Object, ByVal e As KeyEventArgs) Handles SearchBox.KeyDown
If e.KeyCode = Keys.Enter Then
Dim SearchString As String
SearchString = SearchBox.Text
Dim URL As String
URL = ("https://www.example.com/search.php?search=" + SearchString)
Process.Start(URL)
End If
End Sub
关于vb.net - 当用户在 ToolStripTextBox (VB.NET) 中按下 "Enter",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/575311/