我已经尝试了
TextBox1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString
但我回来了:
Object reference not set to an instance of an object.
我已经做了一些调试,我可以将url写入调试终端,但似乎我无法做出任何相同的CType(TabControl1.SelectedTab.Controls.Item(0),WebBrowser).Url.ToString
编辑: 我已经解决了这个问题
将此放入表单中加载:
AddHandler wb.DocumentCompleted, AddressOf WebBrowser1_DocumentCompleted_1
然后把它放入你的代码:
Private Sub WebBrowser1_DocumentCompleted_1(sender As Object, e As WebBrowserDocumentCompletedEventArgs)
TextBox1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString
End Sub
答案 0 :(得分:0)
试试这个:
将网络浏览器添加到tabcontrol1
Dim ja As New WebBrowser
Dim uri As New Uri("www.google.com")
ja.Url = uri
Dim i As New TabPage
i.Controls.Add(ja)
TabControl1.TabPages.Add(i)
将url检入tabchanged
Dim j As WebBrowser
j = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser)
j.Update()
MessageBox.Show(j.Url.ToString)