Results 1 to 4 of 4

Thread: refrencing a new instance of a webbrowser

  1. #1

    Thread Starter
    Banned
    Join Date
    Dec 2006
    Location
    India
    Posts
    89

    refrencing a new instance of a webbrowser

    hey all
    ive created a form with a tabcontrol and im also successfully able to create new tabs with new webbrowser instances on them during runtime but even when the new tab is open still the new url that i type in the textbox it gets navigated on the old tab only.
    How do i make the new url typed open in the new tab
    since i wont know the new tabpage name?

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: refrencing a new instance of a webbrowser

    How exactly are you creating new instances? Can you post some code?

  3. #3

    Thread Starter
    Banned
    Join Date
    Dec 2006
    Location
    India
    Posts
    89

    Re: refrencing a new instance of a webbrowser

    hey man im sorry i posted this in the wrong forum this is meant for vb 2005 express edition

    VB Code:
    1. Public Class Form1
    2.     Public browser As WebBrowser
    3.     Private Sub ToolStripButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton6.Click
    4.         If Me.TabControl1.SelectedTab.Focus Then
    5.             WebBrowser1.Navigate(ToolStripComboBox1.Text)
    6.         Else
    7.             Me.TabControl1.SelectedTab.Focus()
    8.             browser.Navigate(ToolStripComboBox1.Text)
    9.         End If
    10.     End Sub
    11.     ' Updates the title bar with the current document title.
    12.     Private Sub webBrowser1_DocumentTitleChanged( _
    13.         ByVal sender As Object, ByVal e As EventArgs) _
    14.         Handles WebBrowser1.DocumentTitleChanged
    15.         Me.Text = WebBrowser1.DocumentTitle
    16.         TabPage1.Text = WebBrowser1.DocumentTitle
    17.     End Sub
    18.     Private Sub NewTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewTabToolStripMenuItem.Click
    19.         Me.TabControl1.TabPages.Add(New BrowserTabPage)
    20.         Me.TabControl1.SelectedTab.Focus()
    21.     End Sub
    22.     Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
    23.  
    24.     End Sub
    25.  
    26.     Private Sub TabPage1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabPage1.Click
    27.  
    28.     End Sub
    29. End Class
    30. Public Class BrowserTabPage
    31.     Inherits TabPage
    32.  
    33.     Private browser As WebBrowser
    34.  
    35.     Public Sub New()
    36.         MyBase.New()
    37.         Me.browser = New WebBrowser
    38.         Me.browser.Dock = DockStyle.Fill
    39.         Me.Controls.Add(Me.browser)
    40.     End Sub
    41.     Public Sub New(ByVal url As String)
    42.         Me.New()
    43.         Me.browser.Navigate(url)
    44.     End Sub
    45. End Class
    Last edited by si_the_geek; Dec 11th, 2006 at 03:06 PM. Reason: added vbcode tags

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: refrencing a new instance of a webbrowser

    Moved, and added vbcode tags

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