[RESOLVED] Help with axwebbrowser control
Hello everyone,
Soemone please help me do this...
I have a list of url's in a listbox.Im trying to make the axwebbrowser navigate to the next item as soon as the document has loaded for one item.
Ive been trying this,but i dont know,it seems to act so wierd.
I know how to use the "for loop",but please understand,its not workingg..I trieddd. :( so,help me
I just want the axwebbrowser to navigate through all the urls in the listbox one by one and then just stop.
Im using vs2003 btw :)
Thanks a tonne...Thankk youuu :)
Re: Help with axwebbrowser control
Post your code for the for loop. And by not working what do you mean?
Re: Help with axwebbrowser control
Quote:
Originally Posted by mpdeglau
Post your code for the for loop. And by not working what do you mean?
ah! Smart guy :ehh:
ok,ill just post the code
Re: Help with axwebbrowser control
heres the code guys..
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
newsub(Me.AxWebBrowser1, Me.ListBox1)
End Sub
Private Sub newsub(ByVal browser As AxSHDocVw.AxWebBrowser, ByVal lstbox As ListBox)
For i As Integer = 0 To (lstbox.Items.Count - 1)
browser.Navigate(lstbox.Items.Item(i))
Next
End Sub
In another scenario,I tried this...
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
newsub(Me.AxWebBrowser1, Me.ListBox1)
End Sub
Private Sub newsub(ByVal browser As AxSHDocVw.AxWebBrowser, ByVal lstbox As ListBox)
For i As Integer = 0 To (lstbox.Items.Count - 1)
fixit: If setme = True Then
setme = False
browser.Navigate(lstbox.Items.Item(i))
Else
MsgBox("doesnt work")
End If
Next
End Sub
Private Sub AxWebBrowser1_DocumentComplete(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent) Handles AxWebBrowser1.DocumentComplete
setme = True
End Sub
Both dont work as expected...some logical error...so,help me please :)
Re: Help with axwebbrowser control
Ok. This is what you are trying to do, correct me if I am wrong.
You have a list of documents that you want to open in your browser.
You want to load them in one at a time
You want the next document to wait to load until the loading doc is done
Is that correct?
Something that you could try is this:
VB Code:
Private NextPage as Integer = 0
Private Sub Button1_Click(sender...) Handles Button1.Click
AxWebBrowser1.Navigate(lstbox.Items.Item(NextPage))
End Sub
Private Sub Private Sub AxWebBrowser1_DocumentComplete(sender...) Handles AxWebBrowser1.DocumentComplete
NextPage += 1
If NextPage < lstbox.Items.Count Then
AxWebBrowser1.Navigate(lstbox.Items.Item(NextPage))
Else
NextPage = 0
End If
End Sub
This should work if my understanding of what you want to do is correct. Just note I typed this in ie so it is untested and there may be a few errors you need to fix.
Re: Help with axwebbrowser control
Hi,
You're code changes the browsercontrols page only when you click the button.
What you said is exactly right,but I want to automate that process.Once the first page is done,it should automatically go to the next url in the listbox :)
Thanks
Re: Help with axwebbrowser control
That's what the code should do. You click the button to start the cycle, then in the DocumentComplete event it moves onto the next page, which should cause it to keep going until all pages are loaded.
Re: Help with axwebbrowser control
it works :-s but it didnt work when i tried something like this before...maybe I did some mistake..
Thanks :)
Re: Help with axwebbrowser control
Hey,a slight modification..
This is how it should be :)
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
NextPage = 0
AxWebBrowser1.Navigate(lstbox.Items.Item(NextPage))
End Sub
Private Sub AxWebBrowser1_DocumentComplete(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent) Handles AxWebBrowser1.DocumentComplete
' MsgBox(lstbox.Items.Item(NextPage))
If NextPage < lstbox.Items.Count Then
AxWebBrowser1.Navigate(lstbox.Items.Item(NextPage))
NextPage += 1
End If
End Sub
Thanks a bunch bud :)