Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Possible? Access Dynamic Controls

Status
Not open for further replies.

mlager

Programmer
Sep 1, 2006
74
US
I've got a tab control that I dynamically create tabs for each record in a dataset. In each tab, a web browser control is dynamically created as well. It looks like this:

For Each Row As DataRow In DataSet.Tables("Pages").Rows
TabControl1.TabPages.Add(Row.Item("tab_title"), Row.Item("tab_title"))
Dim WebBrowser As New WebBrowser
TabControl1.TabPages(Row.Item("tab_title").ToString()).Controls.Add(WebBrowser)
WebBrowser.Dock = DockStyle.Fill
WebBrowser.Navigate(Row.Item("url").ToString())
Next

It works well. Each tab is created, with its browser, and then the page is loaded. No problem there. Now suppose I wanted to create a "refresh" button or a "back / forward" button within each tab to navigate the web browser, how would I do this? As far as I know, each browser is named "WebBrowser" and the Visual Studio GUI doesn't even recognize WebBrowser outsize of that sub routine I pasted above.

How do I handle this? Thanks in advance for any advice.
 
I figured it out. Seemed I needed to name the WebBrowser control (via the name property) and then define it in other parts of the code such as:

Dim WebBrowser As WebBrowser
WebBrowser = TabControl1.TabPages("Tab Name").Controls.Item("1")
WebBrowser.Refresh()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top