|
-
Feb 23rd, 2008, 03:32 PM
#1
Thread Starter
New Member
[2008] Update textbox?
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
-
Feb 23rd, 2008, 03:35 PM
#2
Re: [2008] Update textbox?
have you tried:
TextBox1.Text = WebBrowser1.Location.tostring ???
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 23rd, 2008, 03:37 PM
#3
Re: [2008] Update textbox?
i'm assuming you want to show the physical location of the webbrowser control in the textbox?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 23rd, 2008, 03:39 PM
#4
Re: [2008] Update 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.
-
Feb 23rd, 2008, 03:39 PM
#5
Hyperactive Member
Re: [2008] Update 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
If my post helps , please feel free to rate it 
-
Feb 23rd, 2008, 03:55 PM
#6
Thread Starter
New Member
Re: [2008] Update textbox?
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 .
-
Feb 23rd, 2008, 03:59 PM
#7
Thread Starter
New Member
Re: [2008] Update textbox?
I tried:
Code:
TextBox1.Text = WebBrowser1.Location.tostring
That didn't work, so I tried
Code:
TextBox1.Text = WebBrowser1.URL.tostring
It showed the correct URL, but now, you cannot type in the textbox.
-
Feb 23rd, 2008, 04:06 PM
#8
Re: [2008] Update textbox?
as Atheist said
 Originally Posted by Atheist
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.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 23rd, 2008, 04:09 PM
#9
Thread Starter
New Member
Re: [2008] Update textbox?
So, does anyone know what I am to do?
 Originally Posted by Tinbeard
btw Welcome to the forum
Thanks.
-
Feb 23rd, 2008, 04:15 PM
#10
Re: [2008] Update textbox?
can't you set textbox1.text when you change the url, instead of in the TextChanged event handler?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 23rd, 2008, 04:17 PM
#11
Thread Starter
New Member
Re: [2008] Update textbox?
I'm not that experienced
-
Feb 23rd, 2008, 04:30 PM
#12
Re: [2008] Update textbox?
show us what code you've got + we might be able to help you more
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 23rd, 2008, 05:06 PM
#13
Thread Starter
New Member
Re: [2008] Update textbox?
Do you want the entire code, or just that part?
-
Feb 23rd, 2008, 05:10 PM
#14
Re: [2008] Update textbox?
the more information the better
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 23rd, 2008, 05:15 PM
#15
Thread Starter
New Member
Re: [2008] Update textbox?
Heres form1 :
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
I think thats all you need, but heres AboutBox:
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
-
Feb 23rd, 2008, 05:31 PM
#16
Re: [2008] Update textbox?
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
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 23rd, 2008, 05:33 PM
#17
Thread Starter
New Member
Re: [2008] Update textbox?
You did it on lines 28-30, correct?
-
Feb 23rd, 2008, 05:34 PM
#18
Re: [2008] Update textbox?
Set it when the WebBrowsers DocumentCompleted event fires.
-
Feb 23rd, 2008, 05:36 PM
#19
Re: [2008] Update textbox?
i was just about to have a look at the webbrowser control.....
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 23rd, 2008, 05:37 PM
#20
Thread Starter
New Member
Re: [2008] Update textbox?
Okay, uhm, whatever it is doing :S . Isn't going to work x_X
-
Feb 23rd, 2008, 05:40 PM
#21
Re: [2008] Update textbox?
 Originally Posted by Atheist
Set it when the WebBrowsers DocumentCompleted event fires.
do what Atheist said. it should work
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 23rd, 2008, 05:41 PM
#22
Re: [2008] Update textbox?
First off, remove all occurances of this in your code:
vb Code:
TextBox1.Text = WebBrowser1.Url.ToString
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.
An event-handler for that event will be created. Place this in it:
vb Code:
TextBox1.Text = e.Url.ToString()
Thats all.
-
Feb 23rd, 2008, 05:45 PM
#23
Thread Starter
New Member
Re: [2008] Update textbox?
 Originally Posted by Atheist
First off, remove all occurances of this in your code:
vb Code:
TextBox1.Text = WebBrowser1.Url.ToString
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.
An event-handler for that event will be created. Place this in it:
vb Code:
TextBox1.Text = e.Url.ToString()
Thats all.
Awesome! Thanks so much everyone. I have another question, but I will make a new topic.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|