-
Jun 14th, 2019, 08:45 PM
#1
Thread Starter
Lively Member
[RESOLVED] How To Access A New Declared Web Browser
vb.net Code:
Dim page As New TabPage(String.Format("T " & (x_Count), TabControl1.TabPages.Count + 1))
TabControl1.TabPages.Add(page)
Dim browser As New WebBrowser()
page.Controls.Add(browser)
browser.Dock = DockStyle.Fill
browser.Navigate(TextBox3.Text)
This is the code I am using to create a new tab with a new web browser in it. However, how would I direct a "Web Browser Refresh" function or a "Navigate" button to these newly declared Web Browsers? What I have come up with is closing the tab and just reopening it with the specified URL, but that isn't hardly practical at all.
Any tips? Thanks you guys!
-
Jun 14th, 2019, 09:32 PM
#2
Re: How To Access A New Declared Web Browser
If you're using standard controls then the obvious option is this:
vb.net Code:
TabControl1.SelectedTab.Controls.OfType(Of WebBrowser)().Single().Navigate(theNewUrl)
This assumes that you want to affect the currently selected TabPage and it will always have one and only one WebBrowser control on it.
That said, you may find it more useful to create your own custom controls and build the functionality you need into them, rather than just using the standard controls and fussing every time. Follow the CodeBank link in my signature below and check out my Tabbed Web Browser thread for an example of that.
-
Jun 14th, 2019, 09:50 PM
#3
Thread Starter
Lively Member
Re: How To Access A New Declared Web Browser
Originally Posted by jmcilhinney
If you're using standard controls then the obvious option is this:
vb.net Code:
TabControl1.SelectedTab.Controls.OfType(Of WebBrowser)().Single().Navigate(theNewUrl)
This assumes that you want to affect the currently selected TabPage and it will always have one and only one WebBrowser control on it.
That said, you may find it more useful to create your own custom controls and build the functionality you need into them, rather than just using the standard controls and fussing every time. Follow the CodeBank link in my signature below and check out my Tabbed Web Browser thread for an example of that.
I’ll look into that. Ultimately, that’s what I’ll want is to figure out how to my make my own custom controls. Thank you!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|