Visual Basic '10 Help with changing a WebBrowser via RadioButtons
9 replies, posted
Hello, I have this code so that when someone clicks on a radiobutton it changes the Webbrowser to the page that it is told to although it doesn't do anything at all. I'm only new to VB so any help is much appreciated.
Here is the code:
[CODE] Private Sub WebBrowser1_DocumentCompleted() Handles WebBrowser1.DocumentCompleted
If RadioButton1.Checked = True Then
WebBrowser1.Navigate("http://buildversions.webs.com/Build106.html")
WebBrowser1.Stop()
ElseIf RadioButton2.Checked = True Then
WebBrowser1.Navigate("http://buildversions.webs.com/Build120.html")
ElseIf RadioButton3.Checked = True Then
WebBrowser1.Navigate("http://buildversions.webs.com/Build168.html")
ElseIf RadioButton4.Enabled = True Then
WebBrowser1.Navigate("http://buildversions.webs.com/Build200.html")
End If
End Sub[/CODE]
I tried changing Handles WebBrowser1.DocumentCompleted to WebBrowser.Navigated and it works but it continuously keeps refreshing meaning I cant really view the page
try using the radiobutton's CheckChanged event
Apparently there is no CheckChanged event only Checked.
There should be a CheckedChanged event, it's been there since .NET 1.1
[url]http://msdn.microsoft.com/en-us/library/system.windows.forms.radiobutton.checkedchanged.aspx[/url]
[editline]4th September 2011[/editline]
although I suppose the Checked event would work as well...
Yeah exactly, I believe this is some other problem but I have not been able to find anyone actually using radio buttons this way lol
I don't have Visual Studio for VB installed, only C#, but I'm pretty sure the layout is exactly the same.
So, do this:
Click the RadioButton
[img]http://img809.imageshack.us/img809/4261/screenshot2011090409062.png[/img]
Go to the events area
[img]http://img13.imageshack.us/img13/5439/screenshot2011090409065.png[/img]
Find CheckChanged
[img]http://img696.imageshack.us/img696/2032/screenshot2011090409071.png[/img]
Double tap it to be greeted by some automatically generated code
[img]http://img5.imageshack.us/img5/7039/screenshot2011090409073.png[/img]
Put your code, that should be run when the radioButton's checkState is changed, inside.
Cheers!
Thanks mate,
I'll try it when I get back home and tell you how it went :P
It worked! I'll try and remember this for next time. For other people, you don't need to change anything, just add in the webbrowser1.navigate("URL HERE") and it works fine.
You're probably the only one in this section who uses VB.NET guv! :v:
Glad to see you got it working though.
Cheers! :)
Meh I might upgrade to something harder later but it does what I want for now :D
Sorry, you need to Log In to post a reply to this thread.