如何以编程方式滚动到System.Windows.Forms.WebBrowser的末尾?
Tar*_*ier 15
ctlWebBrowser.Document.Body.ScrollIntoView(false);
Run Code Online (Sandbox Code Playgroud)
ScrollIntoView()的布尔参数为true以使滚动条与文档顶部对齐,false为将滚动条与文档底部对齐.
这里的MSDN文档:HtmlElement.ScrollIntoView
ycl*_*vnc 12
我正在设置控件的DocumentText属性WebBrowser(使用html和body标签),Document.Body.ScrollIntoView(false)方法对我不起作用,但这是有效的:
private void ScrollToBottom()
{
// MOST IMP : processes all windows messages queue
Application.DoEvents();
if (webBrowser1.Document != null)
{
webBrowser1.Document.Window.ScrollTo(0, webBrowser1.Document.Body.ScrollRectangle.Height);
}
}
Run Code Online (Sandbox Code Playgroud)
来源:http://kiranpatils.wordpress.com/2010/07/19/webbrowsercontrol-scroll-to-bottom/