我是相當新的vb.net,我知道的基本知識。我有這個代碼來爲我的c:Drive上的目錄中的每個pdf文件生成多個Tabs。該代碼還爲每個Tab生成一個webbrowser,併爲每個webbrowser分配正確的pdf。有些pdf與其他pdf的鏈接。當我點擊這些鏈接時,pdf將在父頁面的pdf瀏覽器中打開。我創建了一個使用web.goback()命令的按鈕,但它什麼都不做。我想查看鏈接的pdf,然後點擊返回到主要pdf。使用GoBack的(),在代碼中的多個代碼產生的網頁瀏覽器選項卡
Imports System.IO
Public Class Form1
Dim theweb As New WebBrowser
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For Each A As String In System.IO.Directory.GetFiles("N:\Drawing Office\Standards Appplication\PDF")
Dim A2 As String = System.IO.Path.GetFileNameWithoutExtension(A)
Dim myTabPage As New TabPage()
myTabPage.Text = A2
TabControl1.TabPages.Add(myTabPage)
Dim theweb As New WebBrowser
Dim Url As String = A
theweb.GoHome()
theweb.Parent = myTabPage
theweb.Visible = True
theweb.Dock = DockStyle.Fill
theweb.Navigate(Url)
Next
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
theweb.GoBack()
End Sub
End Class
我已經更新我用下面的代碼。它工作完美。唯一的問題是,當我點擊「Button1」時,它會刷新並自動返回到第一個標籤,即使您在第15個標籤上忙碌。
Imports System.IO
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For Each A As String In System.IO.Directory.GetFiles("N:\Drawing Office\Standards Appplication\PDF")
Dim A2 As String = System.IO.Path.GetFileNameWithoutExtension(A)
Dim myTabPage As New TabPage()
myTabPage.Text = A2
TabControl1.TabPages.Add(myTabPage)
Dim theweb As New WebBrowser
Dim Url As String = A
theweb.GoHome()
theweb.Parent = myTabPage
theweb.Visible = True
theweb.Dock = DockStyle.Fill
theweb.Navigate(Url)
Next
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
testIt()
End Sub
Private Sub testIt()
TabControl1.TabPages.Clear()
For Each A As String In System.IO.Directory.GetFiles("N:\Drawing Office\Standards Appplication\PDF")
Dim A2 As String = System.IO.Path.GetFileNameWithoutExtension(A)
Dim myTabPage As New TabPage()
myTabPage.Text = A2
TabControl1.TabPages.Add(myTabPage)
Dim theweb As New WebBrowser
Dim Url As String = A
theweb.GoHome()
theweb.Parent = myTabPage
theweb.Visible = True
theweb.Dock = DockStyle.Fill
theweb.Navigate(Url)
Next
End Sub
End Class
試過了。不起作用。 –