【发布时间】:2019-04-03 15:43:36
【问题描述】:
在 winforms 中,我正在创建一个基于 Gecko 的浏览器,我需要在创建新标签页时将 geckoBrowser1、urlBar1 (not yet added) 和 back/forwardArrow1 (not yet added) 添加到新标签页中。我的问题是复制这些特定资产
我已经尝试在 google 上查找内容,但他们都在谈论如何从头开始添加新标签页。
private void button1_Click(object sender, EventArgs e)
{
//newTab is the "New Tab" button
GeckoWebBrowser geckoWebBrowser1 = new GeckoWebBrowser();
string title = "tabPage" + (tabControl1.TabCount + 1).ToString();
TabPage tabPage = new TabPage(title);
tabControl1.TabPages.Add(tabPage);
//I want to add the geckoWebBrowser1 into a new tab here
if (newTab.Location.X < Form1.ActiveForm.Width - 50)
{
newTab.Location = new Point(60 * tabControl1.TabCount - 2, 0);
}
else
{
newTab.Location = new Point(newTab.Location.X, newTab.Location.Y);
}
}
我希望我创建的新选项卡能够使用 Gecko 浏览器并将其复制到新选项卡中。
【问题讨论】:
-
我看起来您应该将浏览器控件包装到 UserControl 和/或基于 TabPage 创建 CustomControl。