开发者

VB.NET TabControl Web Browser?

开发者 https://www.devze.com 2023-04-06 03:12 出处:网络
I\'m a bit new to this, but I\'m working on a web browser with tabbed browsing, however.. When a new tab is created, it creates a web browser in it - but I want a function called when the browser is

I'm a bit new to this, but I'm working on a web browser with tabbed browsing, however..

When a new tab is created, it creates a web browser in it - but I want a function called when the browser is finished loading. I can't create a private sub inside a function, So I am not sure what I should do. Any Ideas?

My Code:

Function addtab()
    Dim myTabPage As New TabPage()
    Dim theweb As New WebBrowser

    myTabPage.Text = "TabPage Test" & (TabControl1.TabPages.Count + 1)
    TabControl1.TabPages.Add(myTabPage)

    theweb.GoHome()
    theweb.Parent = myTabPage
    theweb.Vis开发者_运维问答ible = True
    theweb.Dock = DockStyle.Fill
    Return True
End Function

Thanks!


Sounds like you want to create a new webBrowser object, dock it in the new tabPage you make and then have the webBrowser do something when it's finished loading, correct?

What about something like this...

Public Class Form1

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    addtab()
End Sub

Function addtab()
    Dim myTabPage As New TabPage()
    Dim theweb As New WebBrowser()
    AddHandler theweb.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf Run_Me_On_Load)
    myTabPage.Text = "TabPage Test" & (TabControl1.TabPages.Count + 1)
    TabControl1.TabPages.Add(myTabPage)
    theweb.Navigate("http://justinchoponis.com")
    theweb.Parent = myTabPage
    theweb.Visible = True
    theweb.Dock = DockStyle.Fill
    Return True
End Function


Public Sub Run_Me_On_Load(sender As Object, e As EventArgs)
    MessageBox.Show("Finished loading")
End Sub

End Class

0

精彩评论

暂无评论...
验证码 换一张
取 消