Export (0) Print
Expand All

HtmlDocument.GetElementFromPoint Method

Retrieves the HTML element located at the specified client coordinates.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public HtmlElement GetElementFromPoint(
	Point point


Type: System.Drawing.Point

The x,y position of the element on the screen, relative to the top-left corner of the document.

Return Value

Type: System.Windows.Forms.HtmlElement
The HtmlElement at the specified screen location in the document.

GetElementFromPoint uses client coordinates, in which the upper-left corner of the document is assigned the value (0,0). Client coordinates for the current position of the cursor can be obtained using the Position property.

The following code example detects a click on the document, finds the element, and uses ScrollIntoView to align the element with the top of the Web page.

private void Document_Click(Object sender, HtmlElementEventArgs e)
    if (webBrowser1.Document != null)
        HtmlElement elem = webBrowser1.Document.GetElementFromPoint(e.ClientMousePosition);

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft