Results 1 to 3 of 3

Thread: [2008] Tabbed Pages Problems

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2008
    Posts
    30

    [2008] Tabbed Pages Problems

    I'm sorry I keep having problems. But this will prob. be one of my last for a while. I am having a problem with my tabbed browser. What I did was I put in a code like this
    Code:
    Private Sub ToolStripButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton5.Click
            webbrowser.Navigate(txturl.Text)
            WebBrowser1.Navigate(txturl.Text)
        End Sub
    What I am trying to do is have Multible tab in which when you go to one webpage it stays on that tab, and is not displayed on the other tab (so you can have google on one tab and yahoo! Mail on the other). What is happening is that when I type in a url in one tab it also shows in the other tab. There are no errors showing.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: [2008] Tabbed Pages Problems

    Quote Originally Posted by ajwak95
    I'm sorry I keep having problems. But this will prob. be one of my last for a while. I am having a problem with my tabbed browser. What I did was I put in a code like this
    Code:
    Private Sub ToolStripButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton5.Click
            webbrowser.Navigate(txturl.Text)
            WebBrowser1.Navigate(txturl.Text)
        End Sub
    What I am trying to do is have Multible tab in which when you go to one webpage it stays on that tab, and is not displayed on the other tab (so you can have google on one tab and yahoo! Mail on the other). What is happening is that when I type in a url in one tab it also shows in the other tab. There are no errors showing.
    thats because you're telling both webbrowser + WebBrowser1 to .Navigate(txturl.Text)

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

    Re: [2008] Tabbed Pages Problems

    Here's what I suggest for a tabbed Web browser. You inherit the TabPage class and add a constructor that creates a WebBrowser control and adds it to the page. You would then either expose that WebBrowser control via a public property, which is easier, or else declare members in your TabPage class that in turn access the corresponding members of the WebBrowser control. Here's an example of the first option:
    vb.net Code:
    1. Public Class WebBrowserTabPage
    2.     Inherits System.Windows.Forms.TabPage
    3.  
    4.     Private WithEvents _webBrowser As New WebBrowser
    5.  
    6.     Public ReadOnly Property WebBrowser() As WebBrowser
    7.         Get
    8.             Return Me._webBrowser
    9.         End Get
    10.     End Property
    11.  
    12.     Public Sub New()
    13.         Me._webBrowser.Dock = DockStyle.Fill
    14.         Me.Controls.Add(Me._webBrowser)
    15.     End Sub
    16.  
    17.     Private Sub _webBrowser_DocumentTitleChanged(ByVal sender As Object, _
    18.                                                  ByVal e As EventArgs) Handles _webBrowser.DocumentTitleChanged
    19.         Me.Text = Me.WebBrowser.DocumentTitle
    20.     End Sub
    21.  
    22. End Class
    Now, instead of adding regular TabPages, you add instances of your WebBrowserTabPage to your TabControl. You will have to do this in code, which you'd do anyway as you opened knew pages:
    vb.net Code:
    1. Me.TabControl1.TabPages.Add(New WebBrowserTabPage)
    Now it's easy to ensure you refer to only the browser on the selected tab:
    vb.net Code:
    1. DirectCast(Me.TabControl1.SelectedTab, WebBrowserTabPage).WebBrowser.Navigate("URL here")
    Also, if you're using a single address bar and the like you can handle the SelectedIndexChanged event of the TabControl and get the correct address easily to display.
    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

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