Jason
Jason

Reputation: 29

TabControl with browser

I am trying to add new tabs to my control using a button, when it adds it I want to auto add a browser to it. Was wondering would making anew browser for each tab be bad or would I just delete the browser if I leave a tab and add it if I click on a tab?

When I click my button so far it adds a new tab but no browser is added. Thanks for any help!

        String title = "List " + (tabControl1.TabCount + 1).ToString();
        WebBrowser Browser = new WebBrowser();
        tabControl1.TabPages.Add(title);
        tabControl1.SelectTab(tabControl1.TabCount-1);
        //Browser.Name = "Web Browser";
        Browser.Dock = DockStyle.Fill;
        tabControl1.SelectedTab.Controls.Add(Browser);

Upvotes: 0

Views: 202

Answers (1)

Hans Passant
Hans Passant

Reputation: 941277

No, a browser is definitely getting added. It will be hard to see since you don't load any document in the browser, it just looks the same as a completely empty TabPage. Arbitrarily add this line to have something to look at:

  Browser.DocumentText = title;

Get ahead by adding the code to set the browser's Url property so it will load a real web page.

Upvotes: 1

Related Questions