Click here to Skip to main content
11,480,082 members (54,917 online)
Rate this: bad
Please Sign up or sign in to vote.

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
Edited 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
0 OriginalGriff 235
1 Sergey Alexandrovich Kryukov 215
2 Richard MacCutchan 100
3 F-ES Sitecore 75
4 DamithSL 65
0 Sergey Alexandrovich Kryukov 7,890
1 OriginalGriff 7,556
2 Sascha Lefèvre 3,064
3 Maciej Los 2,491
4 Richard Deeming 2,335

Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 24 Dec 2012
Copyright © CodeProject, 1999-2015
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