public Form1()
        {
            InitializeComponent();
            tabControl1.TabPages.Clear();                // Get rid of any existing pages in the tab control
            Create_a_new_tab();                          // This method creates a new tab, new webbrowser and opens the default page.
            WebBrowser webpage = GetCurrentWebBrowser(); // Get the current webpage and..
            webpage.GoHome();                            // ...display the default page.
        }
private void Create_a_new_tab()
        {
            // Add a new tab control, and put a web control in it.
            // Let's have a maxium of 10 tabs to keep things sane.            if (current_tab_count == 10) return;            // Create the new tab page
            TabPage newpage = new TabPage("Loading...");    // Create the new page
            tabpages.Add(newpage);                          // Add the page to an arraylist to keep track of it.
            tabControl1.TabPages.Add(newpage);              // Add the page to the TabControl so it actually appears
        
            // Keep track of how many pages are open.
            current_tab_count++;            // Create a new WebBrowser control.
            WebBrowser webpage = new WebBrowser();          // Create the new control
            webpages.Add(webpage);                          // Add the control to an arraylist to keep track of it.
            webpage.Parent = newpage;                       // Make sure the WebControl's parent is the TabControl page
            webpage.Dock = DockStyle.Fill;                  // Make the WebControl fill the entire TabControl page.
            
            // We define a handler to perform some actions when the document has been fetched and displayed.
            // We need to do this as the WebControl will work in the background, and we need to know when it has
            // finished so we can switch off the animation timer, and update the name of the Tab with the
            // the document title.
            webpage.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webpage_DocumentCompleted);
           // webpage.GoHome();                               // Display the default page.
            timer1.Enabled = true;                          // Start the timer for animating the little logo in the top right.            // Bring the new page to the foreground
            tabControl1.SelectedTab = newpage;
                
        }
        private WebBrowser GetCurrentWebBrowser()
        {
            // This method returns the currently display WebControl.
            // We use an arraylist of webpages, and find the right one by getting the index
            // of the current tab.            TabPage current_tab = tabControl1.SelectedTab;
            WebBrowser thiswebpage = (WebBrowser)webpages[tabpages.IndexOf(current_tab)];
            return thiswebpage;
        }