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:
- This gives me an exception: Object reference not set to an instance of an object.
-
So I tried looping through the controls in the
tabMain.SelectedTaband 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
try this.
I assume
tabMainis the name of theTabControl. If this is true and each tab has aWebBrowserControl in it then it should work.