Jump to content
ferreira12

utilizaçao de 2 WebBrowser

Recommended Posts

ferreira12

Boas.

Eu tenho o primeiro link que carrega uma informação através de uns parâmetros que eu lhe mando, e só depois de ela carregar a informação é que o outro link funciona, pois está dependente do anterior.

Eu em teste estou a usei 2 botoes, em que o primeiro carrega o primeiro link, e só depois de carregado e que clico no outro botão de modo a carregar a informaçao do segundo link.

Mas eu gostaria de colocar isto mais pratico/automático.

Não existe nenhum método que verifique que o WebBrowser1 está carregado, então carrega o WebBrowser2?

Share this post


Link to post
Share on other sites
cdaniel.marques

DocumentCompleted?

Exemplo:

Private Sub PrintHelpPage()
   ' Create a WebBrowser instance. 
   Dim webBrowserForPrinting As New WebBrowser()
   ' Add an event handler that prints the document after it loads.
   AddHandler webBrowserForPrinting.DocumentCompleted, New _
    WebBrowserDocumentCompletedEventHandler(AddressOf PrintDocument)
   ' Set the Url property to load the document.
   webBrowserForPrinting.Url = New Uri("\\myshare\help.html")
End Sub
Private Sub PrintDocument(ByVal sender As Object, _
   ByVal e As WebBrowserDocumentCompletedEventArgs)
   Dim webBrowserForPrinting As WebBrowser = CType(sender, WebBrowser)
   ' Print the document now that it is fully loaded.
   webBrowserForPrinting.Print()
   MessageBox.Show("print")
   ' Dispose the WebBrowser now that the task is complete.
   webBrowserForPrinting.Dispose()
End Sub

Fonte:

http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.documentcompleted.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

Share this post


Link to post
Share on other sites
andrempv

uhm vendo isso bem só tenho duas ideas

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
 If WebBrowser1.Url.ToString = "Seu link" Then ' Se o seu link for este abre o webrowser2
	 Webrowser2.show()
 End If

End sub

Outra maneira

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
	 Webrowser2.show() 'quando o site estiver carregado abrir o webrowser 2
 End If

End Sub

Mais simples? impossivel.

Edited by andrempv

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.