HtmlDocument.Click 事件

定义

当用户单击文档上的任何位置时发生。

public:
 event System::Windows::Forms::HtmlElementEventHandler ^ Click;
public event System.Windows.Forms.HtmlElementEventHandler Click;
member this.Click : System.Windows.Forms.HtmlElementEventHandler 
Public Custom Event Click As HtmlElementEventHandler 

事件类型

HtmlElementEventHandler

示例

下面的代码示例检测单击文档、查找元素,并使用 ScrollIntoView 该元素与网页顶部对齐。

private void Document_Click(Object sender, HtmlElementEventArgs e)
{
    if (webBrowser1.Document != null)
    {
        HtmlElement elem = webBrowser1.Document.GetElementFromPoint(e.ClientMousePosition);
        elem.ScrollIntoView(true);
    }
}
Private Sub Document_Click(ByVal sender As Object, ByVal e As HtmlElementEventArgs)
    If (WebBrowser1.Document IsNot Nothing) Then
        Dim Elem As HtmlElement = WebBrowser1.Document.GetElementFromPoint(e.ClientMousePosition)
        Elem.ScrollIntoView(True)
    End If
End Sub

注解

有关处理事件的详细信息,请参阅 “处理和引发事件”。

适用于

另请参阅