Home All Groups Group Topic Archive Search About
Author
8 Sep 2006 10:38 PM
Lance
Hi All,

Given a collection of links, how can I send them to a WebBrowser Control so
that I can manipulate it's document?  Ok, that's way too simplified of a
question.  I know how to send a link to a WebBrowser:

/////
WebBroweser1.Navigate(Link)
/////

but I can figure out how to send several links in succession.  In my test,
I've got a simple collection that contains 5 strings.  Pressing a command
button performs:

/////
For Each s As String In links
WebBrowser1.Navigate(s)
Next
/////

and in the WebBrowser1's DocumentCompleted Event is:

/////
Dim doc As HtmlDocument = WebBrowser1.Document
Debug.Print(doc.Url.ToString)
/////

However, the only Url string ever printed to the immediate window is the
last one in the collection, and all the WebBrowser1 window ever shows is
that last webpage.

I realize this probably has something to do with synchronization, but I'm
not sure how to resolve this.

Thanks,
Lance

Author
9 Sep 2006 12:18 AM
GhostInAK
Hello Lance" chuckyboy81070-at-onehotpotatoimeanhotmail.com,

..Navigate() is an asynch method.  The navigation and remdering is passed
off to the web browser control, which uses a separate thread(s) to do the
work.. and immediately returns from the .Navigate method.

The correct method for navigating multiple URLs in succession.. which you
should have guessed from your investigations had you just applied yourself..
is to navigate to each successive URL from within the DocumentCompleted event.

-Boo

Show quoteHide quote
> Hi All,
>
> Given a collection of links, how can I send them to a WebBrowser
> Control so that I can manipulate it's document?  Ok, that's way too
> simplified of a question.  I know how to send a link to a WebBrowser:
>
> /////
> WebBroweser1.Navigate(Link)
> /////
> but I can figure out how to send several links in succession.  In my
> test, I've got a simple collection that contains 5 strings.  Pressing
> a command button performs:
>
> /////
> For Each s As String In links
> WebBrowser1.Navigate(s)
> Next
> /////
> and in the WebBrowser1's DocumentCompleted Event is:
>
> /////
> Dim doc As HtmlDocument = WebBrowser1.Document
> Debug.Print(doc.Url.ToString)
> /////
> However, the only Url string ever printed to the immediate window is
> the last one in the collection, and all the WebBrowser1 window ever
> shows is that last webpage.
>
> I realize this probably has something to do with synchronization, but
> I'm not sure how to resolve this.
>
> Thanks,
> Lance
Author
9 Sep 2006 1:38 AM
Lance
Thanks Boo.  You're right, I would have eventually figured that out.  I
tried for several hours and just thought I'd drop a note to the group before
the weekend.

Thanks again,
Lance

Show quoteHide quote
"GhostInAK" <ghosti***@gmail.com> wrote in message
news:be1391bf175808c8a1799764d8d6@news.microsoft.com...
> Hello Lance" chuckyboy81070-at-onehotpotatoimeanhotmail.com,
>
> .Navigate() is an asynch method.  The navigation and remdering is passed
> off to the web browser control, which uses a separate thread(s) to do the
> work.. and immediately returns from the .Navigate method.
>
> The correct method for navigating multiple URLs in succession.. which you
> should have guessed from your investigations had you just applied
> yourself.. is to navigate to each successive URL from within the
> DocumentCompleted event.
>
> -Boo
>
>> Hi All,
>>
>> Given a collection of links, how can I send them to a WebBrowser
>> Control so that I can manipulate it's document?  Ok, that's way too
>> simplified of a question.  I know how to send a link to a WebBrowser:
>>
>> /////
>> WebBroweser1.Navigate(Link)
>> /////
>> but I can figure out how to send several links in succession.  In my
>> test, I've got a simple collection that contains 5 strings.  Pressing
>> a command button performs:
>>
>> /////
>> For Each s As String In links
>> WebBrowser1.Navigate(s)
>> Next
>> /////
>> and in the WebBrowser1's DocumentCompleted Event is:
>>
>> /////
>> Dim doc As HtmlDocument = WebBrowser1.Document
>> Debug.Print(doc.Url.ToString)
>> /////
>> However, the only Url string ever printed to the immediate window is
>> the last one in the collection, and all the WebBrowser1 window ever
>> shows is that last webpage.
>>
>> I realize this probably has something to do with synchronization, but
>> I'm not sure how to resolve this.
>>
>> Thanks,
>> Lance
>
>
>