[英]C# windows form browser control .DocumentCompleted event on .aspx pages
[英]Change size of web browser control in DocumentCompleted
我在Winform中有一個Web瀏覽器控件。 為了完全顯示Web內容(沒有滾動條),我需要在DocumentComplete事件中獲取Web內容的大小。 然后調整(刷新)winform的大小。
void wbControl_DocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
{
wbControl.Height = wbControl.Document.Window.Size.Height;
wbControl.Width = wbControl.Document.Window.Size.Width;
}
但是,它沒有從這里設置。 舊值保持不變。
如果Document.Window.Size
不能解決問題, Document.Body.ScrollRectangle
通常將為您工作。
由於窗體的邊界,在調整窗體大小時,我添加了一些寬度和高度,而僅調整控件本身的大小時,則不必這樣做。
private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
//If dockstyle = fill
this.Width = webBrowser.Document.Body.ScrollRectangle.Width + 40;//Border
this.Height = webBrowser.Document.Body.ScrollRectangle.Height + 40;//Border
//If the control is not docked
webBrowser.Size = webBrowser.Document.Body.ScrollRectangle.Size;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.