Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net VB选项卡控件自动指向新单击的选项卡_Vb.net_Tabs_Controls - Fatal编程技术网

Vb.net VB选项卡控件自动指向新单击的选项卡

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中的链接时,新的选项卡链接在我点击后不会自动重定向,而是停留在第一页


任何帮助都将不胜感激

你在点击哪个链接,你是怎么做的?我在你发布的代码中没有看到这一点。只需添加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