I am making a simple browser, and when I try this code it will not build.
Code:Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
TextBox1.Text = WebBrowser1.Location()
End Sub
Printable View
I am making a simple browser, and when I try this code it will not build.
Code:Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
TextBox1.Text = WebBrowser1.Location()
End Sub
have you tried:
TextBox1.Text = WebBrowser1.Location.tostring ???
i'm assuming you want to show the physical location of the webbrowser control in the textbox?
1. Always provide as much relevant information as possible, you havent told us the error you're getting. However in this case its pretty simple to see what the problem is.
2. You're trying to directly assign a 'Point' (the Location property returns a 'Point') to a String property. You must assign a String to a String property.
3. You're setting the Text of TextBox1 in the TextChanged event handler, which will result in the user not being able to write anything in the textbox.
Your trying to assign a system drawing point to a textbox, this won't work.
What are you trying to do here ?
btw Welcome to the forum :)
I am just trying to show the user where they are on the web, because now, if you type google.com and click on something, it stays google.com .
I tried:
That didn't work, so I triedCode:TextBox1.Text = WebBrowser1.Location.tostring
It showed the correct URL, but now, you cannot type in the textbox.Code:TextBox1.Text = WebBrowser1.URL.tostring
as Atheist said
Quote:
Originally Posted by Atheist
So, does anyone know what I am to do?
Thanks.Quote:
Originally Posted by Tinbeard
can't you set textbox1.text when you change the url, instead of in the TextChanged event handler?
I'm not that experienced:lol:
show us what code you've got + we might be able to help you more
Do you want the entire code, or just that part?
the more information the better
Heres form1 :
I think thats all you need, but heres AboutBox:Code:Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.GoBack()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
WebBrowser1.GoBack()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
WebBrowser1.Stop()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
WebBrowser1.Refresh()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("http://bubbabrowser.sourceforge.net")
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
WebBrowser1.Navigate(TextBox1.Text)
End Sub
Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
AboutBox.ShowDialog()
End Sub
Private Sub AboutToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem1.Click
AboutBox.Show()
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
TextBox1.Text = WebBrowser1.Url.ToString
End Sub
End Class
Code:Imports System.Windows.Forms
Public Class AboutBox
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
End Sub
Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub
End Class
basically wherever you change the webbrowser web address you need to update the textbox.
vb Code:
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click WebBrowser1.GoBack() TextBox1.Text = WebBrowser1.Url.ToString End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click WebBrowser1.GoBack() TextBox1.Text = WebBrowser1.Url.ToString End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click WebBrowser1.Stop() TextBox1.Text = WebBrowser1.Url.ToString End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click WebBrowser1.Refresh() TextBox1.Text = WebBrowser1.Url.ToString End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load WebBrowser1.Navigate("http://bubbabrowser.sourceforge.net") TextBox1.Text = WebBrowser1.Url.ToString End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click WebBrowser1.Navigate(TextBox1.Text) TextBox1.Text = WebBrowser1.Url.ToString End Sub Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) AboutBox.ShowDialog() End Sub Private Sub AboutToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem1.Click AboutBox.Show() End Sub Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click Me.Close() End Sub End Class
but don't do it in TextBox1_TextChanged
You did it on lines 28-30, correct?
Set it when the WebBrowsers DocumentCompleted event fires.
i was just about to have a look at the webbrowser control.....
Okay, uhm, whatever it is doing :S . Isn't going to work x_X
do what Atheist said. it should workQuote:
Originally Posted by Atheist
First off, remove all occurances of this in your code:
Then, in the code view, you'll see a drop-down list on the upper left corner by the code, select your WebBrowser control in it. Now the drop-down list to the right will be filled with Events for the WebBrowser control, simply select the DocumentCompleted event in it.vb Code:
TextBox1.Text = WebBrowser1.Url.ToString
An event-handler for that event will be created. Place this in it:
Thats all.vb Code:
TextBox1.Text = e.Url.ToString()
Awesome! Thanks so much everyone. I have another question, but I will make a new topic.Quote:
Originally Posted by Atheist