Ok, i have a web browser, and i would like to add tabs, like in firefox and IE 7 when it is released... What i want is for the user to select say Tab 1 and then type in google.com, then go to tab 2 and go to yahoo.com then be able to work between the two with any URL and just 1 Address bar between them both... Thanks!!
well just how do i do it? do i need tab indexing... im a sort of newbie and quite confused.. is it easy?
It depends on how you want to do it.
With an application I made before (BinaryEdit) I threw a toolbar on. Then, as new tabs were opened and closed, I added a new toolbar button. When you click on the button, it shows the document. It is a simple and kind of hacky implimentation. Check it out to see if that's how you want it or if you want them to look like actual tabs.
If you want a more tab like look, you could still use my method but you paint the buttons. That or you could look for a free tab control somewhere. You could also just use a tab control from VS and put your web browser on each tab page. That would work too.
KrisSiegel.com - My Personal Website with my blog and portfolio Don't Forget to Rate Posts!
ohh i know what i need to do! I need it so when the person clicks a different tab, it changes the code from say navigate.webbrowser1 to navigate.webbrowser2 and i need it to change the url
Edit: how do i get it so they can open / close tabs
Well, I'm having trouble understanding the concept. Do I "clone" the first tabpage but rename the web browser control or what?
You need one TabControl and multiple TabPages, each containing a WebBrowser control. The TabPage class has no Clone method and it wouldn't help you anyway because it would simply creat a new, empty TabPage. What I would suggest is defining your own class that inherits the TabPage class and includes code to add a WebBrowser control to itself when its created, e.g.
VB Code:
Public Class BrowserTabPage
Inherits TabPage
Private browser As WebBrowser
Public Sub New()
MyBase.New()
Me.browser = New WebBrowser
Me.browser.Dock = DockStyle.Full
Me.Controls.Add(Me.browser)
End Sub
'...
End Class
Now when you want to add a new tab to your browser you just do this:
I get an error stating : Too Many Arguemnets to Public Sub New()
Does your TabBrowser type have a constructor that takes a String argument? You can't just pass whatever parameters you feel like to a method. If it's your class and you haven't written a method that accepts and uses those arguments then what do you expect to happen to them?
Sorry for the double post but how would I know which web browser to Navigate?
Read about the TabControl and its members and it will (should) be clear.
You need one TabControl and multiple TabPages, each containing a WebBrowser control. The TabPage class has no Clone method and it wouldn't help you anyway because it would simply creat a new, empty TabPage. What I would suggest is defining your own class that inherits the TabPage class and includes code to add a WebBrowser control to itself when its created, e.g.
VB Code:
Public Class BrowserTabPage
Inherits TabPage
Private browser As WebBrowser
Public Sub New()
MyBase.New()
Me.browser = New WebBrowser
Me.browser.Dock = DockStyle.Full
Me.Controls.Add(Me.browser)
End Sub
'...
End Class
Now when you want to add a new tab to your browser you just do this:
VB Code:
Me.TabControl1.TabPages.Add(New BrowserTabPage)
hey do we need to have a tab page as the browser loads
i think its a better idea to put a webbrowser onto the form first and on top of that a tab control so that the first site u visit opens in the webbrowser without the tab control showing and when we click on file->new tab the tab control visibility is set to true and a second tabpage opens but can we access the webbrowser 1 on the first tab page or is there a way i can hide the tab in the tab control when the browser loads so that i will be working on tab page 1
without the tab being visible
I want the tab to be visible only once a new tab is opened
and i should be working in the second tab...
hey do we need to have a tab page as the browser loads
i think its a better idea to put a webbrowser onto the form first and on top of that a tab control so that the first site u visit opens in the webbrowser without the tab control showing and when we click on file->new tab the tab control visibility is set to true and a second tabpage opens but can we access the webbrowser 1 on the first tab page or is there a way i can hide the tab in the tab control when the browser loads so that i will be working on tab page 1
without the tab being visible
I want the tab to be visible only once a new tab is opened
and i should be working in the second tab...
If you want to do it that way then I'd suggest adding another constructor that takes a WebBrowser as a parameter. Then you can remove the existing WebBrowser from the form and pass it to the first TabPage you create, which will then add it to itself and display it.
one more thing man
using ur method
how will i direct the navigation of the webbrowser created on the new form
i wont know the new webbrowsername
and using ur method after i open a new tab and submit a location the site opens in the first tab not the second
what do i do to navigate the webbrowser on the new tab
hey i think u dint get me
i have already created a tabcontrol with one tabpage on it and a webbrowser on that tabpage but when i click new tab a new tab gets created with a new webbrowser on it so i need to know the new webbrowser name to be able to navigate to the site on the new webbrowser
hey i think u dint get me
i have already created a tabcontrol with one tabpage on it and a webbrowser on that tabpage but when i click new tab a new tab gets created with a new webbrowser on it so i need to know the new webbrowser name to be able to navigate to the site on the new webbrowser
No, I know exactly what you're talking about, and I'm saying that you don't need to know anything about the WebBrowser on the new tab. All you need to know about is the new TabPage. You tell the TabPage to display a URL and the TabPage tells the WebBrowser. You already have a reference to the TabPage because you just created it, and the there is only one WebBrowser control on the TabPage so there's no mistake to be made. You just do this:
Its not working, hey what do i have to put for the go button?
i think there is a problem with that
please check my code for the go button:
Private Sub ToolStripButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton6.Click
If Me.TabPage1.Focus Then
WebBrowser1.Navigate(ToolStripComboBox1.Text)
ElseIf Me.TabControl1.TabPages.Contains(New BrowserTabPage("www.vbforums.com")) Then
browser.Navigate(ToolStripComboBox1.Text)
End If
End Sub
Your Else block is never going to work. You're checking whether the TabControl contains a TabPage that you've just created, which will never be True. If you want to get a reference to the browser on the current tab you'd use the TabControl's SelectedTab property.
i dont have a selectedtab property for the tabcontrol maybe because i have vb 2005 express edition
wow i wish i had a property like that, life would be much simpler
is there any other way i could get a reference to the browser on the current tab?
Please reply soon...
im really looking forward to completing the browser soon....
please tell me what code i exactly have to use for the go button
Look a bit harder. A TabControl is a TabControl and a TabControl has a SelectedTab property, whether you're using VS Pro, VB Express, #Develop, Delphi, Notepad or whatever. You're using classes from the .NET Framework and those classes don't change regardless of what you're using to develop your application.
hey i get an error when i open a new tab, enter a url and click go
is this part of the code below correct? ElseIf Me.TabControl1.SelectedTab.Focus Then
Me.browser.Navigate(ToolStripComboBox1.Text)
VB Code:
Private Sub ToolStripButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton6.Click
If Me.TabPage1.Focus = True Then
WebBrowser1.Navigate(ToolStripComboBox1.Text)
ElseIf Me.TabControl1.SelectedTab.Focus Then
Me.browser.Navigate(ToolStripComboBox1.Text)
End If
End Sub
Am i supposed to use Me.browser.Navigate(ToolStripComboBox1.Text)
or what do i use to call the new browser
Last edited by ethicalhacker; Dec 4th, 2006 at 12:21 AM.