问题描述
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;usingTileBrowserDemo.Custom;usingCefSharp.WinForms;namespaceTileBrowserDemo{publicpartialclassMainWindow:Form{publicMainWindow(){InitializeComponent();AddBreowser();}privatevoidAddBreowser(){ChromiumWebBrowserb=newChromiumWebBrowser("www.baidu.com"){MinimumSize=newSize(800,600),};//只用代码A是没问题的/*代码AflowLayoutPanel.SuspendLayout();b.Parent=this.flowLayoutPanel;flowLayoutPanel.ResumeLayout();**///用代码B却根本就加载不了浏览器//代码B,本意是要在等浏览器初始化完成后,再加入到父容器上b.IsBrowserInitializedChanged+=b_IsBrowserInitializedChanged;}voidb_IsBrowserInitializedChanged(objectsender,CefSharp.IsBrowserInitializedChangedEventArgse){varb=(ChromiumWebBrowser)sender;flowLayoutPanel.SuspendLayout();b.Parent=this.flowLayoutPanel;flowLayoutPanel.ResumeLayout();}}}