2

I have try a complete firefox in windows form application. I add some add tab page but can't a close by click. I have no idea to paste a cross button on the tab page.My coding part is :-

private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (tabControl1.SelectedTab.Text == "+")
        {
            AddNewTab();
        }
        foreach (Control item in tabControl1.SelectedTab.Controls)
        {
            if (item.GetType() == typeof(WebBrowser))
            {
                WebBrowser wb = (WebBrowser)item;
                toolStripButton1.Enabled = wb.CanGoBack;
                toolStripButton2.Enabled = wb.CanGoForward;
            }
        }
        this.wb.DocumentTitleChanged += Browser_DocumentTitleChanged;
        this.wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
    }

enter image description here

my closed function--

 private void tabPage1_Click(object sender, EventArgs e)
    {
        if (tabControl1.SelectedTab != null)
        {
            tabControl1.SelectedTab.Dispose();
        }
    }

this function is closed the tab page by double click , I want to closed the tab page with the help of button same as FireFox working

j.s.banger
  • 412
  • 1
  • 6
  • 15

1 Answers1

2

What you want to do is outside the scope of the TabControl.

To do this, you would need to create a Custom Control.

In your custom control, you could add a small PictureBox with the image of a + and some text on a Label and several Panel controls.

Code the + Click Event to call your closing technique.

Code the Label's Click Event to show different Panels in your form with your HTML pages.

EDIT: Like Brian was kind enough to point out below, here is an excellent tutorial on how to do this on CodeProject:

CodeProject: FireFox-like Tab Control
Screenshot

  • plz can you share a coding part – j.s.banger Mar 07 '13 at 19:07
  • Thanks Brian. To @j.s.banger: Creating a custom control is not exactly trivial and the code would need to be specific to your application (i.e. **Custom**). –  Mar 07 '13 at 19:19
  • Did you click on the link that Brian provided? It has an excellent tutorial showing how to do exactly what you are trying to recreate. –  Mar 07 '13 at 19:59