PCI Techie
PCI Techie

Reputation: 13

How do I clone everything inside a tabpage in code while creating a new tabpage

In winforms I am creating a browser based off of Gecko and I need the geckoBrowser1, urlBar1 (not yet added) and back/forwardArrow1 (not yet added) to be added to a new tabPage upon it's creation. My issue is copying these particular assets

I've already tried looking things up on google but they all talk about how to add a new tabpage from scratch.

    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);
        }
    }

I expect the new tab I create to then take the Gecko browser and duplicate it into the new tab.

Upvotes: 0

Views: 64

Answers (1)

Mikev
Mikev

Reputation: 2082

Something like this:

tabPage.Controls.Add(geckoWebBrowser1); 

Upvotes: 1

Related Questions