0

WebBrowser在课堂上使用课堂。我正在尝试添加 webbrowser_documentcomplete 事件处理程序,但我发现该事件没有触发。请在下面找到我正在使用的代码。此代码适用于 Windows 窗体但不在课堂上。

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
4

1 回答 1

1

您的 DocumentCompleted 事件的签名是:

    (ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs)

令编译器感到惊讶的是,编译器并没有对此犹豫不决。

于 2012-12-24T23:06:57.193 回答