问题描述
你好社区!
我在按新URL时制作标签时遇到了大问题
I have a big problem regarding on making tabs when pressing a new URL
对于启动,我有以下代码来创建选项卡,并为创建另一个选项卡提供了一个按钮,这很简单:
I have this code for the start up to make the tab and a button to make another tab this is simple:
将昏暗"标签设为新的TabPage
将newtab设为新标签
newtab.Show()
newtab.Dock = DockStyle.Fill
newtab.TopLevel = False
tab.Controls.Add(newtab)
Me.TabControl1.TabPages.Add(tab)
Me.TabControl1.SelectedTab =选项卡
Dim tab As New TabPage
Dim newtab As New tabs
newtab.Show()
newtab.Dock = DockStyle.Fill
newtab.TopLevel = False
tab.Controls.Add(newtab)
Me.TabControl1.TabPages.Add(tab)
Me.TabControl1.SelectedTab = tab
但是当按下链接并试图打开一个新标签时,我得到了这段代码,但是它坏了.
But when a link is pressed and is trying to open a new tab i have this code but its broken.
将WithEvents公开作为新的WebBrowser
Public WithEvents wb As New WebBrowser
e.Cancel = True
'AddHandler browserTabControl1.SelectedIndexChanged,AddressOf tabcontrolchangeinputs
将此元素变暗为HtmlElement = WebBrowser1.Document.ActiveElement
Dim targeturl As String = thiselement.GetAttribute("href")
将newtab变暗为新的TabPage
browser.TabControl1.Controls.Add(newtab)
将新形式变暗为新形式
newform.Dock = DockStyle.Fill
newform.FormBorderStyle = Windows.Forms.FormBorderStyle.None
newform.TopLevel = False
newtab.Controls.Add(newform)
newform.Show()
newform.Controls.Add(wb)
browser.TabControl1.SelectedTab = newtab
browser.TabControl1.SelectedTab.Controls.Add(newform)
wb.Dock = DockStyle.Fill
wb.Navigate(targeturl)
e.Cancel = True
'AddHandler browserTabControl1.SelectedIndexChanged, AddressOf tabcontrolchangeinputs
Dim thiselement As HtmlElement = WebBrowser1.Document.ActiveElement
Dim targeturl As String = thiselement.GetAttribute("href")
Dim newtab As New TabPage
browser.TabControl1.Controls.Add(newtab)
Dim newform As New Form
newform.Dock = DockStyle.Fill
newform.FormBorderStyle = Windows.Forms.FormBorderStyle.None
newform.TopLevel = False
newtab.Controls.Add(newform)
newform.Show()
newform.Controls.Add(wb)
browser.TabControl1.SelectedTab = newtab
browser.TabControl1.SelectedTab.Controls.Add(newform)
wb.Dock = DockStyle.Fill
wb.Navigate(targeturl)
请帮助!
预先感谢!
推荐答案
Dim newtab As New TabPage
browser.TabControl1.Controls.Add(newtab)
newtab.Controls.Add(wb)
wb.Show()
browser.TabControl1.SelectedTab = newtab
wb.Dock = DockStyle.Fill
wb.Navigate(targeturl)
这篇关于网页浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!