Vb.net VB选项卡控件自动指向新单击的选项卡
你好,请帮我修改我的程序,我想我的问题对你来说很简单。当我点击tabcontrol1中的链接时,新的选项卡链接在我点击后不会自动重定向,而是停留在第一页Vb.net VB选项卡控件自动指向新单击的选项卡,vb.net,tabs,controls,Vb.net,Tabs,Controls,你好,请帮我修改我的程序,我想我的问题对你来说很简单。当我点击tabcontrol1中的链接时,新的选项卡链接在我点击后不会自动重定向,而是停留在第一页 任何帮助都将不胜感激 你在点击哪个链接,你是怎么做的?我在你发布的代码中没有看到这一点。只需添加TabControl1.SelectedTab=tp Option Strict On Option Explicit On Public Class Form1 Declare the webbrowser and a url stri
任何帮助都将不胜感激 你在点击哪个链接,你是怎么做的?我在你发布的代码中没有看到这一点。只需添加TabControl1.SelectedTab=tp
Option Strict On
Option Explicit On
Public Class Form1
Declare the webbrowser and a url string
Private browser As WebBrowser
Private urlString As String = "http://stackoverflow.com/questions/ask"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Calls the sub "newTab"
newTab()
End Sub
Private Sub newTab()
'Creates a new instance of the webbrowser
browser = New WebBrowser
'Sets the webbrowser's properties
With browser
.Navigate(urlString)
.Dock = DockStyle.Fill
End With
'Declare a new tabpage and add it to the tabcontrol
Dim tp As New TabPage("New Tab")
TabControl1.Controls.Add(tp)
'Add the webbrowser to the tabpage
tp.Controls.Add(browser)
'Create a new instance of the NewWindow for the new webbrowser
AddHandler browser.NewWindow, AddressOf BrowserNewWindow
End Sub
Private Sub BrowserNewWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
'Stops the new window
e.Cancel = True
Dim element As HtmlElement = Browser.Document.ActiveElement
Dim url As String = element.GetAttribute("href")
urlString = url
'Calls the sub "newTab"
newTab()
End Sub
End Class