Results 1 to 6 of 6
  1. #1
    Xizors's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Posts
    568
    Reputation
    18
    Thanks
    94

    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!

  2. #2
    Lyoto Machida's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Far away with girls
    Posts
    3,734
    Reputation
    133
    Thanks
    1,621
    My Mood
    Aggressive
    Make a button "Navigate" or..
    Use GetAsyncKeyState..

    If you use a button you can always do on the form_load:
    Me.AcceptButton = NavigateButton

  3. The Following User Says Thank You to Lyoto Machida For This Useful Post:

    Xizors (06-10-2011)

  4. #3
    NOOB's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Posts
    3,843
    Reputation
    425
    Thanks
    8,616
    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

  5. The Following User Says Thank You to NOOB For This Useful Post:

    Xizors (06-11-2011)

  6. #4
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    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.



  7. #5
    Lyoto Machida's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Far away with girls
    Posts
    3,734
    Reputation
    133
    Thanks
    1,621
    My Mood
    Aggressive
    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

  8. #6
    Xizors's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Posts
    568
    Reputation
    18
    Thanks
    94
    Thanks for the help

    Please mark as Solved.