HtmlDocument.GetElementFromPoint(Point) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Retrieves the HTML element located at the specified client coordinates.
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
Parameters
- point
- Point
The x,y position of the element on the screen, relative to the top-left corner of the document.
Returns
The HtmlElement at the specified screen location in the document.
Examples
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);
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
Remarks
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.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기