I was wondering if its possible to get the absolute position of specific HTML element I have loaded in webbrowser control with C#.
I tried almost all of the options that
Just sharing a slightly different implementation based on my needs to get the absolute positioning rectangle:
public Rectangle GetAbsoluteRectangle(HtmlElement element) {
//get initial rectangle
Rectangle rect = element.OffsetRectangle;
//update with all parents' positions
HtmlElement currParent = element.OffsetParent;
while (currParent != null) {
rect.Offset(currParent.OffsetRectangle.Left, currParent.OffsetRectangle.Top);
currParent = currParent.OffsetParent;
}
return rect;
}