EDN Admin
Well-known member
Hi all.
I seem to be having a problem whenever I remove a newly created tab which had a Web Browser automatically added to that tab, within TabControl1, and then adding a new tab after that tab was removed.
So how would I make a fully functional "Remove Tab" feature within my Web Browser?
Here is the code I used to help explain the problem better:
<pre class="prettyprint lang-vb" style=" Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TabControl1.SelectTab(SelectedTab)
End Sub
Dim SelectedTab As Integer = 0
Private Sub AddNewTab_Click( sender As Object, e as EventArgs) Handles AddNewTab.Click
Dim NewWebBrowser as New WebBrowser
Dim NewTab As New TabPage
TabControl1.TabPages.Add(NewTab)
TabControl1.SelectTab(SelectedTab)
TabControl1.SelectedTab.Controls.Add(NewWebBrowser)
NewWebBrowser.Dock = DockStyle.Fill
NewWebBrowser.Name = "Web Browser"
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.google.co.uk")
SelectedTab = SelectedTab + 1
End Sub
Private Sub RemoveTab_Click( sender As Object, e as EventArgs) Handles RemoveTab.Click
If Not TabControl1.TabCount = 1 Then
TabControl1.TabPages.Remove(TabControl1.SelectedTab)
SelectedTab = SelectedTab - 1
End Sub[/code]
<br/>
<br/>
<br/>
View the full article
I seem to be having a problem whenever I remove a newly created tab which had a Web Browser automatically added to that tab, within TabControl1, and then adding a new tab after that tab was removed.
So how would I make a fully functional "Remove Tab" feature within my Web Browser?
Here is the code I used to help explain the problem better:
<pre class="prettyprint lang-vb" style=" Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TabControl1.SelectTab(SelectedTab)
End Sub
Dim SelectedTab As Integer = 0
Private Sub AddNewTab_Click( sender As Object, e as EventArgs) Handles AddNewTab.Click
Dim NewWebBrowser as New WebBrowser
Dim NewTab As New TabPage
TabControl1.TabPages.Add(NewTab)
TabControl1.SelectTab(SelectedTab)
TabControl1.SelectedTab.Controls.Add(NewWebBrowser)
NewWebBrowser.Dock = DockStyle.Fill
NewWebBrowser.Name = "Web Browser"
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.google.co.uk")
SelectedTab = SelectedTab + 1
End Sub
Private Sub RemoveTab_Click( sender As Object, e as EventArgs) Handles RemoveTab.Click
If Not TabControl1.TabCount = 1 Then
TabControl1.TabPages.Remove(TabControl1.SelectedTab)
SelectedTab = SelectedTab - 1
End Sub[/code]
<br/>
<br/>
<br/>
View the full article