关于这篇文章“HtmlElementEventHandler Delegate” http://msdn.microsoft.com/en-us/library/system.windows.forms.htmlelementeventhandler.aspx
上下文菜单事件处理程序多次触发。你如何抑制重复事件的触发?
这是我的代码:
公共事件 DocumentCompleted As WebBrowserDocumentCompletedEventHandler
Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
Dim Doc As HtmlDocument = Me.WebBrowser1.Document
AddHandler Doc.ContextMenuShowing, New HtmlElementEventHandler(AddressOf Document_ContextMenuShowing)
Dim htmldoc As HtmlDocument = Me.WebBrowser1.Document
End Sub
Private Sub Document_ContextMenuShowing(ByVal sender As Object, ByVal e As HtmlElementEventArgs)
Try
Dim doc As HtmlDocument = CType(sender, HtmlDocument)
If doc.ActiveElement.TagName = "A" Then
MsgBox(doc.ActiveElement.InnerHtml)
e.ReturnValue = False
End If
Catch ex As Exception
End Try
End Sub