Results 1 to 32 of 32

Thread: Tabs in a web browser

  1. #1

    Thread Starter
    Addicted Member adamlonsdale's Avatar
    Join Date
    Oct 2005
    Posts
    210

    Exclamation 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!!

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Tabs in a web browser

    ok.... did you have any questions or did you want us to do the work for you?
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  3. #3

    Thread Starter
    Addicted Member adamlonsdale's Avatar
    Join Date
    Oct 2005
    Posts
    210

    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?

  4. #4
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    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.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  5. #5

    Thread Starter
    Addicted Member adamlonsdale's Avatar
    Join Date
    Oct 2005
    Posts
    210

    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...?

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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

  7. #7
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    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.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  8. #8
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.

  9. #9

    Thread Starter
    Addicted Member adamlonsdale's Avatar
    Join Date
    Oct 2005
    Posts
    210

    Re: Tabs in a web browser

    ok, ill give it a go...

  10. #10

    Thread Starter
    Addicted Member adamlonsdale's Avatar
    Join Date
    Oct 2005
    Posts
    210

    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

  11. #11

    Thread Starter
    Addicted Member adamlonsdale's Avatar
    Join Date
    Oct 2005
    Posts
    210

    Re: Tabs in a web browser

    bump

  12. #12
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    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.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  13. #13
    Banned
    Join Date
    Jul 2006
    Location
    Atlanta, GA, USA
    Posts
    28

    Re: Tabs in a web browser

    Er...I need help with this too.

  14. #14
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  15. #15
    Banned
    Join Date
    Jul 2006
    Location
    Atlanta, GA, USA
    Posts
    28

    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?

  16. #16
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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:
    1. Public Class BrowserTabPage
    2.     Inherits TabPage
    3.  
    4.     Private browser As WebBrowser
    5.  
    6.     Public Sub New()
    7.         MyBase.New()
    8.  
    9.         Me.browser = New WebBrowser
    10.         Me.browser.Dock = DockStyle.Full
    11.         Me.Controls.Add(Me.browser)
    12.     End Sub
    13.  
    14.     '...
    15.  
    16. End Class
    Now when you want to add a new tab to your browser you just do this:
    VB Code:
    1. Me.TabControl1.TabPages.Add(New BrowserTabPage)
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  17. #17
    Banned
    Join Date
    Jul 2006
    Location
    Atlanta, GA, USA
    Posts
    28

    Re: Tabs in a web browser

    Ok, thanks. I tweaked it quite a bit. When I use
    VB Code:
    1. TabControl1.TabPages.Add(New TabBrowser("about:blank"))
    I get an error stating : Too Many Arguemnets to Public Sub New()

  18. #18
    Banned
    Join Date
    Jul 2006
    Location
    Atlanta, GA, USA
    Posts
    28

    Re: Tabs in a web browser

    Sorry for the double post but how would I know which web browser to Navigate?

  19. #19
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Tabs in a web browser

    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?
    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  20. #20
    Banned
    Join Date
    Dec 2006
    Location
    India
    Posts
    89

    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:
    1. Public Class BrowserTabPage
    2.     Inherits TabPage
    3.  
    4.     Private browser As WebBrowser
    5.  
    6.     Public Sub New()
    7.         MyBase.New()
    8.  
    9.         Me.browser = New WebBrowser
    10.         Me.browser.Dock = DockStyle.Full
    11.         Me.Controls.Add(Me.browser)
    12.     End Sub
    13.  
    14.     '...
    15.  
    16. End Class
    Now when you want to add a new tab to your browser you just do this:
    VB Code:
    1. 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...

  21. #21
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  22. #22
    Banned
    Join Date
    Dec 2006
    Location
    India
    Posts
    89

    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

  23. #23
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  24. #24
    Banned
    Join Date
    Dec 2006
    Location
    India
    Posts
    89

    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

  25. #25
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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:
    1. myTabControl.TabPages.Add(New BrowserTabPage("www.vbforums.com"))
    and in the BrowserTabPage class you do this:
    VB Code:
    1. Public Class BrowserTabPage
    2.     Inherits TabPage
    3.  
    4.     Private browser As WebBrowser
    5.  
    6.     Public Sub New()
    7.         MyBase.New()
    8.  
    9.         Me.browser = New WebBrowser
    10.         Me.browser.Dock = DockStyle.Full
    11.         Me.Controls.Add(Me.browser)
    12.     End Sub
    13.  
    14.     Public Sub New(ByVal url As String)
    15.         Me.New()
    16.  
    17.         Me.browser.Navigate(url)
    18.     End Sub
    19.  
    20.     '...
    21.  
    22. End Class
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  26. #26
    Banned
    Join Date
    Dec 2006
    Location
    India
    Posts
    89

    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

  27. #27
    Banned
    Join Date
    Dec 2006
    Location
    India
    Posts
    89

    Re: Tabs in a web browser

    the first tab is working but not the new tab

  28. #28
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  29. #29
    Banned
    Join Date
    Dec 2006
    Location
    India
    Posts
    89

    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

  30. #30
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Attached Images Attached Images  
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  31. #31
    Banned
    Join Date
    Dec 2006
    Location
    India
    Posts
    89

    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:
    1. Private Sub ToolStripButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton6.Click
    2.         If Me.TabPage1.Focus = True Then
    3.             WebBrowser1.Navigate(ToolStripComboBox1.Text)
    4.         ElseIf Me.TabControl1.SelectedTab.Focus Then
    5.             Me.browser.Navigate(ToolStripComboBox1.Text)
    6.         End If
    7.     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.

  32. #32
    Banned
    Join Date
    Dec 2006
    Location
    India
    Posts
    89

    Re: Tabs in a web browser

    its always opening in the old tab

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width