Click here to Skip to main content
12,695,365 members (29,893 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# VB VB.NET WebBrowserControl , +

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("", False)
    End Sub

    Private Sub TimCount_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
            TimCount.Enabled = False

// Some Code Goes Here

        Catch ex As Exception
        End Try
    End Sub

    Private Sub WBBrowser_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.EventArgs)
            If WBBrowser.ReadyState <> Windows.Forms.WebBrowserReadyState.Complete Then
            End If
        Catch ex As Exception
        End Try
    End Sub

End Class

Thanks in advance.

[Edit]Code block added[/Edit]
Posted 24-Dec-12 3:44am
Updated 24-Dec-12 4:35am

1 solution

Rate this: bad
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?

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 24 Dec 2012
Copyright © CodeProject, 1999-2017
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