0

I added + and X to my Tab Control from Here and I wanted to add a WebBrowser sized whenever pressed.

Full Code:

        private void tabControl1_MouseDown(object sender, MouseEventArgs e)
        {
            var lastIndex = this.tabControl1.TabCount - 1;
            if (this.tabControl1.GetTabRect(lastIndex).Contains(e.Location))
            {
                this.tabControl1.TabPages.Insert(lastIndex, "New Tab");
                this.tabControl1.SelectedIndex = lastIndex;
                this.tabControl1.TabPages[lastIndex].UseVisualStyleBackColor = true;
                WebBrowser wbb = new WebBrowser();
                wbb.Size = new Size(547, 201);
            }
            else
            {
                for (var i = 0; i < this.tabControl1.TabPages.Count; i++)
                {
                    var tabRect = this.tabControl1.GetTabRect(i);
                    tabRect.Inflate(-2, -2);
                    var closeImage = Properties.Resources.Close;
                    var imageRect = new Rectangle(
                        (tabRect.Right - closeImage.Width),
                        tabRect.Top + (tabRect.Height - closeImage.Height) / 2,
                        closeImage.Width,
                        closeImage.Height);
                    if (imageRect.Contains(e.Location))
                    {
                        this.tabControl1.TabPages.RemoveAt(i);
                        break;
                    }
                }
            }
        }#

Where I am trying to add a Tab:

                this.tabControl1.TabPages.Insert(lastIndex, "New Tab");
                this.tabControl1.SelectedIndex = lastIndex;
                this.tabControl1.TabPages[lastIndex].UseVisualStyleBackColor = true;
                WebBrowser wbb = new WebBrowser();
                wbb.Size = new Size(547, 201);

I want to add a New WebBrowser Sized 547 201 but I have no idea how to get the new Tab added there. I used someones code so I can't figure out how to do it. If there is someway I could add a WebBrowser with that code or other that would be perfectly fine.

If you want to see the full code I used for the Tab Control its in this Link

VWWE
  • 57
  • 5

0 Answers0