HtmlDocument.GetElementFromPoint(Point) メソッド

定義

指定されたクライアント座標にある HTML 要素を取得します。

public:
 System::Windows::Forms::HtmlElement ^ GetElementFromPoint(System::Drawing::Point point);
public System.Windows.Forms.HtmlElement GetElementFromPoint (System.Drawing.Point point);
public System.Windows.Forms.HtmlElement? GetElementFromPoint (System.Drawing.Point point);
member this.GetElementFromPoint : System.Drawing.Point -> System.Windows.Forms.HtmlElement
Public Function GetElementFromPoint (point As Point) As HtmlElement

パラメーター

point
Point

ドキュメントの左上隅を基準とした、画面上の要素の (x,y) 位置。

戻り値

ドキュメント内の指定した画面位置にある HtmlElement

次のコード例では、ドキュメントのクリックを検出し、 を使用 ScrollIntoView して要素を Web ページの上部に配置します。

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

注釈

GetElementFromPoint では、ドキュメントの左上隅に値 (0,0) が割り当てられるクライアント座標が使用されます。 カーソルの現在位置のクライアント座標は、 プロパティを使用して Position 取得できます。

適用対象

こちらもご覧ください