-
Tabs in a web browser
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!!
-
Re: Tabs in a web browser
ok.... did you have any questions or did you want us to do the work for you?
-
Re: Tabs in a web browser
well just how do i do it? do i need tab indexing... im a sort of newbie and quite confused.. is it easy?
-
Re: Tabs in a web browser
Quote:
Originally Posted by adamlonsdale
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.
-
Re: Tabs in a web browser
yeh but if i put each browser on a tab, how will i get the url to navigate to it...?
-
Re: Tabs in a web browser
you would use the tab control, and the webbrowser control
create a new tab and wb control via code for each new tab.
why don't you get started and post back with what you come up with
-
Re: Tabs in a web browser
Quote:
Originally Posted by adamlonsdale
yeh but if i put each browser on a tab, how will i get the url to navigate to it...?
When a user hits enter or clicks a go button, it'll load that page with the currently opened browser.
-
Re: Tabs in a web browser
and when they change tabs, you shoudl change the textbox text to the url of the browser for the tab they changed to.
-
Re: Tabs in a web browser
-
Re: Tabs in a web browser
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
-
Re: Tabs in a web browser
-
Re: Tabs in a web browser
Quote:
Originally Posted by adamlonsdale
Edit: how do i get it so they can open / close tabs
Depends what method you're using for a tab system. If you're using a TabControl, then you just add or remove a TabPage.
-
Re: Tabs in a web browser
Er...I need help with this too.
-
Re: Tabs in a web browser
Quote:
Originally Posted by TH3 K1D
Er...I need help with this too.
So what do you want to know, or are we to just guess?
-
Re: Tabs in a web browser
Well, I'm having trouble understanding the concept. Do I "clone" the first tabpage but rename the web browser control or what?
-
Re: Tabs in a web browser
Quote:
Originally Posted by TH3 K1D
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:
VB Code:
Me.TabControl1.TabPages.Add(New BrowserTabPage)
-
Re: Tabs in a web browser
Ok, thanks. I tweaked it quite a bit. When I use
VB Code:
TabControl1.TabPages.Add(New TabBrowser("about:blank"))
I get an error stating : Too Many Arguemnets to Public Sub New()
-
Re: Tabs in a web browser
Sorry for the double post but how would I know which web browser to Navigate?
-
Re: Tabs in a web browser
Quote:
Ok, thanks. I tweaked it quite a bit. When I use
visual basic code: TabControl1.TabPages.Add(New TabBrowser("about:blank"))
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?
Quote:
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.
-
Re: Tabs in a web browser
Quote:
Originally Posted by jmcilhinney
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...
-
Re: Tabs in a web browser
Quote:
Originally Posted by ethicalhacker
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.
-
Re: Tabs in a web browser
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
-
Re: Tabs in a web browser
If you just created a new TabPage then you've already got a reference to it, so you just tell that TabPage to open the Web page in its WebBrowser.
-
Re: Tabs in a web browser
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
-
Re: Tabs in a web browser
Quote:
Originally Posted by ethicalhacker
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:
VB Code:
myTabControl.TabPages.Add(New BrowserTabPage("www.vbforums.com"))
and in the BrowserTabPage class you do this:
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
Public Sub New(ByVal url As String)
Me.New()
Me.browser.Navigate(url)
End Sub
'...
End Class
-
Re: Tabs in a web browser
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
-
Re: Tabs in a web browser
the first tab is working but not the new tab
-
Re: Tabs in a web browser
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.
-
Re: Tabs in a web browser
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
-
1 Attachment(s)
Re: Tabs in a web browser
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.
-
Re: Tabs in a web browser
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
-
Re: Tabs in a web browser
its always opening in the old tab