From: Sin Jeong-hun on 12 Mar 2010 06:15
I used the WebBrowser control in my C# application. The document
loaded in the WebBrowser is a long dynamically generated page. When
the user select something on the form, I would like to scroll the
document (animation is not required) to a corresponding HtmlElement in
the document, and I want the element is located vertically center in
the WebBrowser control.
I used the HtmlElement's Focus() method. It surely scrolls the
document and brings the element into view, but the element position is
not vertically center. When the document must be scrolled, the element
is located at the top edge or at the bottom edge of the control.
Since I can easily know the center y position (WebBrowser.Height/2), I
was looking for a method to set an element's y position in the
WebControl (not in the document). I couldn't find it.
Is there any way to position an HtmlElement at vertically center in