[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.
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)
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:
Public Class WebBrowserTabPage
Inherits System.Windows.Forms.TabPage
Private WithEvents _webBrowser As New WebBrowser
Public ReadOnly Property WebBrowser() As WebBrowser
Get
Return Me._webBrowser
End Get
End Property
Public Sub New()
Me._webBrowser.Dock = DockStyle.Fill
Me.Controls.Add(Me._webBrowser)
End Sub
Private Sub _webBrowser_DocumentTitleChanged(ByVal sender As Object, _
ByVal e As EventArgs) Handles _webBrowser.DocumentTitleChanged
Me.Text = Me.WebBrowser.DocumentTitle
End Sub
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:
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:
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.