防止WPF web浏览器显示内容的滚动条 [英] Prevent scrollbars with WPF WebBrowser displaying content

查看:803
本文介绍了防止WPF web浏览器显示内容的滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用WPF web浏览器组件来显示一些很简单的HTML内容。然而,因为我不知道事先的内容大小,目前我得到的,当我加载某些数据集控制滚动条。

I'm using the WPF WebBrowser component to display some very simple HTML content. However, since I don't know the content size in advance, I'm currently getting scrollbars on the control when I load certain datasets.

基本上,我怎么能强迫(或以其他方式影响迫使的当量),使得无需滚动显示的所有内容的web浏览器,以在尺寸扩大?

Basically, how can I force (or otherwise effect the equivalent of forcing) the WebBrowser to expand in size so that all content is displayed without the need for scrollbars?

推荐答案

我想你可以得到的宽度,并通过其文件属性WebBrowser组件的内容应该是mshtml.HTMLDocument类型的高度。我相信你应该能够用肢体或documentElement属性来获取所需的大小;水木清华这样的:

I guess you can get width and height of the webbrowser component content through its Document property which should be of mshtml.HTMLDocument type. I believe you should be able to use body or documentElement properties to get needed sizes; smth like this:

mshtml.HTMLDocument htmlDoc = webBrowser.Document as mshtml.HTMLDocument;
if (htmlDoc != null && htmlDoc.body != null)
{
    mshtml.IHTMLElement2 body = (mshtml.IHTMLElement2)htmlDoc.body;
    webBrowser.Width = body.scrollWidth;
    webBrowser.Height = body.scrollHeight;
}



希望这可以帮助,至于

hope this helps, regards

这篇关于防止WPF web浏览器显示内容的滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆