2012-07-20 58 views
1

如何創建webbrowser控件並將單個DocumentComplete事件關聯到它?基本上我想能夠重用相同的DocumentComplete事件,但由於某種原因,它永遠不會停止觸發該事件,所以當我處置webbrowser對象時,它停止觸發事件。但我希望能夠創建另一個控件並重用該事件!創建WebBrowser控件併爲其使用單個DocumentComplete事件

歡呼

回答

1
Dim web1 As New WebBrowser() 
AddHandler web1.DocumentComplete, AddressOf DocumentCompleteEventHandler 
' Do stuff 
RemoveHandler web1.DocumentComplete, AddressOf DocumentCompleteEventHandler 
web1.Dispose() 

Dim web2 As New WebBrowser() 
AddHandler web2.DocumentComplete, AddressOf DocumentCompleteEventHandler 
' Do stuff 
RemoveHandler web2.DocumentComplete, AddressOf DocumentCompleteEventHandler 
web2.Dispose() 
相關問題