Reputation: 992
Programming Environment: Visual Studio 2010
Programming Language: VB.NET
I have a tabbed web-browser that I add dynamically, I Dim
the the web-browser every-time the user clicks the New Tab button, like this: browser = New WebBrowser()
and give it a name based on the tab count, e.g. browser2, if there are 2 tab pages. So my question is - about time - that how would I get the Url of the WebBrowser, I have tried Dim UrlString As String = CType(tabMain.SelectedTab.Controls.Item(browser.Name), WebBrowser).Url.ToString
But, correct me if I am wrong, I found that WebBrowser isn't classed as a Control, and the reason why I think this is because:
So I tried looping through the controls in the tabMain.SelectedTab
and found that the WebBrowser(browser) isn't included in the collection. The code I used to loop was:
For Each ctrl As Control In Me.tabMain.SelectedTab.Controls
MsgBox(ctrl.Name)
Next
Tried looping through all the Parent controls, but no sign of the WebBrowser showing up. Hope this is enough information =P
Thanks in advance.
UPDATE: Figured out the problem, really stupid, and my theory was bullshit too =P. Just ignore =] lol
Upvotes: 0
Views: 1211
Reputation: 36
try this.
Dim UrlString As String = CType(tabMain.Controls.Item(0), WebBrowser).Url.ToString
I assume tabMain
is the name of the TabControl
. If this is true and each tab has a WebBrowser
Control in it then it should work.
Upvotes: 2