Navigate to Url on enter.

Posts 1–6 of 6 · Page 1 of 1
Navigate to Url on enter.
Hello!

Im trying to make my webbrowser navigate to the website in textbox1 when i press enter, but i cant figure out how to do so.

I have tried the following code:
Code:
Private Sub TextBox1_OnEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        OnEnter.WebBrowser1.Navigate(TextBox1.Text)
    End Sub
But i get an error:
Error 1 Overload resolution failed because no accessible 'OnEnter' accepts this number of arguments.

Can someone please help me to get it working?
Thanks!
Make a button "Navigate" or..
Use GetAsyncKeyState..

If you use a button you can always do on the form_load:
Me.AcceptButton = NavigateButton
Code:
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
        If e.KeyCode = Keys.Enter Then
            WebBrowser1.Navigate(TextBox1.Text)
        End If
End Sub
GetAsyncKeyState would be pretty much useless in this example. GetAsyncKeyState is global, meaning even if you don't have your webbrowsers focused, it'll still execute.

Keydown is the best way of doing it in this case.
Quote Originally Posted by Blubb1337 View Post
GetAsyncKeyState would be pretty much useless in this example. GetAsyncKeyState is global, meaning even if you don't have your webbrowsers focused, it'll still execute.

Keydown is the best way of doing it in this case.
Yeah i know, I was trying to remember the code posted by NOOB..But i couldn xD
Thanks for the help

Please mark as Solved.
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us