我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