Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hello,
 
I am using WebBrowser class in class.
I am trying to add webbrowser_documentcomplete event handler but I found that event not firing.
Please find below code I am using. This code working with an Windows Form but not in class.
Imports System.Windows.Forms
Imports System.Threading
 
Public Class GoogleSearch
 
    Dim WithEvents WBBrowser As New Windows.Forms.WebBrowser
    Dim TimCount As New System.Timers.Timer()
 

    Sub New(ByVal SearchParameter As String, ByVal ResultPage As Integer)
 

        TimCount.Interval = 2000
        TimCount.Enabled = False
        AddHandler TimCount.Elapsed, AddressOf TimCount_Tick
 

        WBBrowser.Visible = True
        WBBrowser.ScriptErrorsSuppressed = True
 
        AddHandler WBBrowser.DocumentCompleted, AddressOf WBBrowser_DocumentCompleted
 

        WBBrowser.Navigate("http://www.google.com", False)
    End Sub
 
    Private Sub TimCount_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
        Try
            TimCount.Enabled = False
 
// Some Code Goes Here
 
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
 
    Private Sub WBBrowser_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Try
            If WBBrowser.ReadyState <> Windows.Forms.WebBrowserReadyState.Complete Then
                Return
            Else
                TimCount.Start()
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
 
End Class
Thanks in advance.
 
[Edit]Code block added[/Edit]
Posted 24-Dec-12 2:44am
Edited 24-Dec-12 3:35am
ProgramFOX124.5K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It's not going to work. The WebBrowser control NEEDS to be on a Form in order to work properly.
 
Since this is a class library, you're probably using a web browser control to do something better suited to the HttpRequest classes and methods. What are you doing with this?
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.141015.1 | Last Updated 24 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100