WebBrowser控件调整大小控件、大小、WebBrowser

2023-09-03 04:34:52 作者:我姓王我心亡

我在形式的web浏览器访问一个网站,太宽的控制。我想知道是否有一种方法可以调整大小以适应网站的控制。它似乎很简单,但我还没有找到一种方法呢。我知道如何调整控制,我只需要找到该网站的宽度。当你preSS绿色按钮在Safari会自动调整窗口以正确的大小,就像

I have a WebBrowser in my form that accesses a website that is too wide for the control. I would like to know if there is a way to resize the control to fit the website. It seems simple, but i have not found a way yet. I know how to resize the control, I just need to find the width of the website. Just like when you press the green button in safari it automatically resized the window to the correct size.

推荐答案

您应该能够访问web浏览器的文件的大小和它弄的过WebBrowser.Document.Window.Size大小。

You should be able to access the size of the WebBrowser's Document and get it's size through the WebBrowser.Document.Window.Size.

我会使用WebBrowser控件的DocumentCompleted事件要等到页面加载,然后用你的大小调整code来调整WebControl的容器尺寸本身。

I would use the WebBrowser Controls's DocumentCompleted event to wait until the page is loaded then use your resize code to resize the webControl container with this size.