When the user presses "Enter" in ToolStripTextBox (VB.NET)

I have a ToolStripTextBox (its name is SearchBox), and I would like that after the user types something and presses the enter button, he translates them into a URL. I have a part of the URL sorted, but I need to know what happens after

Handles SearchBox.{what?}

I do not see any event in the intellisense popup for something when the user presses enter.

So, in other words, how do I perform an action after a user types input?

    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
+3
source share
3 answers

Got it from:

delete the input key after clicking on it in the keyup event for

Not exact, but it helped.

    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
+2
source

, URL-!

    Public Sub SearchBox_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs) Handles SearchBox.KeyPress

        Dim messageBoxVB As New System.Text.StringBuilder()
        messageBoxVB.AppendFormat("{0} = {1}", "Enter", e.KeyChar)
        messageBoxVB.AppendLine()


        Dim SearchString As String
        SearchString = SearchBox.Text

        Dim URL As String
        URL = ("https://www.example.com/search.php?search=" + SearchString)

        Process.Start(URL)
    End Sub
End Class

enter?

0

Source: https://habr.com/ru/post/1703651/


All Articles