I have this code for a tabbed web browser:
Public Class Form1
Dim i As Integer = 1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim Browse As New WebBrowser
TabControl1.TabPages.Add(1, "TEST")
TabControl1.SelectTab(i - 1)
Browse.Name = "wb"
Browse.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browse)
i = i + 1
End Sub
End ClassBut there isn't a new tab page! No errors, though...
Offline
I'll get math.... Wait for a few minutes...

Offline
Your problem is that TabPages is a read-only property, therefore when you add an object to it it doesn't reflect that change in the Tab Control. I'll see if I can find a solution.
Offline
TheSuccessor wrote:
Your problem is that TabPages is a read-only property, therefore when you add an object to it it doesn't reflect that change in the Tab Control. I'll see if I can find a solution.
Actually, no. I hooked up the same code to a button, and it worked fine.
Offline
SeptimusHeap wrote:
Bump
![]()
Mine works just look for differences.
Mine. (This works)
TabControl1.Visible = True
Dim newpage As New WebBrowser
TabControl1.TabPages.Add(1, "blank")
TabControl1.SelectTab(i)
newpage.Name = "wb"
newpage.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(newpage)
i = i + 1
Yours.
Dim Browse As New WebBrowser
TabControl1.TabPages.Add(1, "TEST")
TabControl1.SelectTab(i - 1)
Browse.Name = "wb"
Browse.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browse)
i = i + 1
When you add the tab control to your page make sure you remove one of the tabs. The default is two but you are initalizing it as having one.
Last edited by what-the (2011-04-20 19:07:56)
My site Offline
what-the wrote:
SeptimusHeap wrote:
Bump
![]()
Mine works just look for differences.
Mine. (This works)
TabControl1.Visible = True
Dim newpage As New WebBrowser
TabControl1.TabPages.Add(1, "blank")
TabControl1.SelectTab(i)
newpage.Name = "wb"
newpage.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(newpage)
i = i + 1
Yours.
Dim Browse As New WebBrowser
TabControl1.TabPages.Add(1, "TEST")
TabControl1.SelectTab(i - 1)
Browse.Name = "wb"
Browse.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browse)
i = i + 1
When you add the tab control to your page make sure you remove one of the tabs. The default is two but you are initalizing it as having one.
Still doesn't work. I have a tabcontrol with 1 tab.
Offline
Tell me what happens when you debug. Is any thing highlighted in red, yellow or green?
My site Offline
what-the wrote:
Tell me what happens when you debug. Is any thing highlighted in red, yellow or green?
Oddly, no.
Offline
Dim Browse As New WebBrowser
TabControl1.TabPages.Add(1, "TEST")
TabControl1.SelectTab(i)
Browse.Name = "wb"
Browse.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browse)
Browse.Navigate("http://scratch.mit.edu")
i = i + 1
Did you tell the browser to navigate. Copy the above code and see if it works.
Look at "TabControl1.SelectTab(i)"
You have it as TabControl1.SelectTab(i -1)
This is one of the problems. It is making a new browser on top of the old one.
If you want it to switch back to the original tab after making using a variable place holder.
Dim originaltab As Integer = 1
originaltab = TabControl1.SelectedIndex
Dim Browse As New WebBrowser
TabControl1.TabPages.Add(1, "TEST")
TabControl1.SelectTab(i)
Browse.Name = "wb"
Browse.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browse)
Browse.Navigate("http://scratch.mit.edu")
i = i + 1
TabControl1.SelectTab(originaltab)
Last edited by what-the (2011-04-20 19:45:16)
My site Offline
SeptimusHeap wrote:
Still no. The new tab doesn't show up D: try messing wiht my code.
Your code works when I get ride of the - 1
This is your original code. (Note the browser for teh second tab won't be made because the -1 is still there.
Last edited by what-the (2011-04-20 19:50:50)
My site Offline
what-the wrote:
SeptimusHeap wrote:
Still no. The new tab doesn't show up D: try messing wiht my code.
Your code works when I get ride of the - 1
?
Offline
SeptimusHeap wrote:
what-the wrote:
SeptimusHeap wrote:
Still no. The new tab doesn't show up D: try messing wiht my code.
Your code works when I get ride of the - 1
?
This is my current code:
Public Class Form1
Dim i As Integer = 1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim originaltab As Integer = 1
originaltab = TabControl1.SelectedIndex
Dim Browse As New WebBrowser
TabControl1.TabPages.Add(1, "TEST")
TabControl1.SelectTab(i)
Browse.Name = "wb"
Browse.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browse)
Browse.Navigate("http://scratch.mit.edu")
i = i + 1
TabControl1.SelectTab(originaltab)
End Sub
Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
SplitContainer1.Height = Me.Height - 24
SplitContainer1.Width = Me.Width
SplitContainer1.SplitterDistance = 175
End Sub
End Class
With no current open tabs.
Offline
LOL lol lol lol LOL lol lol lol LOL lol lol lol
Add this to the form load; "Handles MyBase.Load".
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
My site Offline
Erm, is there a possible way to add a close button on each tab without heaps of code?
Offline
SeptimusHeap wrote:
TheSuccessor wrote:
Your problem is that TabPages is a read-only property, therefore when you add an object to it it doesn't reflect that change in the Tab Control. I'll see if I can find a solution.
Actually, no. I hooked up the same code to a button, and it worked fine.
I think I might have a different version of VB, looking at the further posts...
Offline