Web Browser Display current web page url in text box or combobox
Web browser question from stupid newb:
How do you make the url of your current web page show up in the navigation combobox or textbox?
The actual problem is when I go to a web page and click an internal link or use the back or forward button it only shows whatever the last webpage I keyed in and not the actual page I'm on.
Any help would be great.
Here's what I have so far:
Quote:
Public Class Form1
Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
WebBrowser1.Navigate(ComboBox1.Text)
WebBrowser1.ScriptErrorsSuppressed = True
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
WebBrowser1.GoBack()
WebBrowser1.ScriptErrorsSuppressed = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Refresh()
WebBrowser1.ScriptErrorsSuppressed = True
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
WebBrowser1.GoForward()
WebBrowser1.ScriptErrorsSuppressed = True
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
WebBrowser1.Navigate("http://www.google.com/#hl=en&source=hp&q=" & ComboBox2.Text)
WebBrowser1.ScriptErrorsSuppressed = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
WebBrowser1.Stop()
WebBrowser1.ScriptErrorsSuppressed = True
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
WebBrowser1.Navigate(urlString:="http://www.buckroberts.com/1_11_Software.html")
WebBrowser1.ScriptErrorsSuppressed = True
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
WebBrowser1.Navigate(ComboBox3.Text)
WebBrowser1.ScriptErrorsSuppressed = True
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
WebBrowser1.Navigate(ComboBox4.Text)
WebBrowser1.ScriptErrorsSuppressed = True
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
End Sub
Private Sub ComboBox4_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox4.SelectedIndexChanged
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
End Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
End Sub
Private Sub ComboBox2_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox2.KeyDown
If e.KeyCode = Keys.Enter Then
Button4.PerformClick()
End If
End Sub
Private Sub ComboBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyDown
If e.KeyCode = Keys.Enter Then
Button3.PerformClick()
End If
End Sub
End Class
Re: Web Browser Display current web page url in text box or combobox
Wait I got it. This seems pretty simple and it works. But there's this annoying ding when press enter. Is there more too it?
Quote:
ComboBox1.Text = WebBrowser1.Url.ToString
Quote:
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
ComboBox1.Text = WebBrowser1.Url.ToString
End Sub