public void AddTab(string url, int?insertIndex = null) { browserTabControl.SuspendLayout(); var browser = new BrowserTabUserControl(AddTab, url, multiThreadedMessageLoopEnabled) { Dock = DockStyle.Fill, }; var tabPage = new TabPage(BrowserTabUserControl.CroppedText(url)) { Dock = DockStyle.Fill }; //This call isn't required for the sample to work. //It's sole purpose is to demonstrate that #553 has been resolved. browser.CreateControl(); tabPage.Controls.Add(browser); if (insertIndex == null) { browserTabControl.TabPages.Add(tabPage); } else { browserTabControl.TabPages.Insert(insertIndex.Value, tabPage); } //Make newly created tab active browserTabControl.SelectedTab = tabPage; browserTabControl.ResumeLayout(true); }
/// <summary> /// Used to add a Popup browser as a Tab /// </summary> /// <param name="browserHostControl"></param> public void AddTab(ChromiumWebBrowser _browser, IWindowInfo winInfo, string url) { browserTabControl.SuspendLayout(); var browser = new BrowserTabUserControl(AddTab, url, multiThreadedMessageLoopEnabled, _browser, winInfo) { Dock = DockStyle.Fill, }; var tabPage = new TabPage(BrowserTabUserControl.CroppedText(url)) { Dock = DockStyle.Fill }; tabPage.Controls.Add(browser); browserTabControl.TabPages.Add(tabPage); //Make newly created tab active browserTabControl.SelectedTab = tabPage; browserTabControl.ResumeLayout(true); }