views:

335

answers:

1

I've tried multiple times to create a web browser with tabbed browsing. I know that I have to use "tab control".

I have succeeded in creating a semi-tabbed browsing. People are able to add new tabs, but the webbrowser component only appears in one tab page.

Coding:

Form1_Load:

 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Browse As New WebBrowser
        TabControl1.TabPages.Add(1, "TabPage" & i)
        TabControl1.SelectTab(1 - 1)
        Browse.Name = "wb"
        Browse.Dock = DockStyle.Fill
        TabControl1.SelectedTab.Controls.Add(Browse)
        i = i + 1
    End Sub

Web Browser Component

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)
    url.Text = e.Url.ToString()
    'your url text box will show the actual url of the page after the page is fully loaded         
    url.Text = e.Url.ToString
    Me.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle & " - Webbrowser's name"
    TabControl1.SelectedTab.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle
End Sub
A: 

When creating a new tab, you should add a new WebBrowser instance to the TabPage as well with a unique name.

dim tbpNewTab as new TabPage
dim wbBrowser as new WebBrowser

wbBrowser.Name = "Browser" & i
tbpNewTab.Text = "TabPage" & i
tbpNewTab.Controls.add(wbBrowser)
TabControl1.TabPages.Add(tbpNewTab)
Rhapsody