Hi there, I'm having a lot of trouble trying to add a new control to a dynamically created TabPage at run time, I have viewed many threads with similar help requests and cant seem to make the codes work! :(

Any help would be greatly appreciated...

Here's what I've got:

Dim albumscount As Xml.XmlNodeList
                        albumscount = config_doc.SelectNodes("component/config/menu/album")
                        i = albumscount.Count - 1
                        Dim albumtitle As Xml.XmlNode
                        Dim newtab As New TabPage
                        Dim x As Integer
                        Dim newctrl As New TextBox
                        For Each albumtitle In albumscount
                            newtab.Name = albumtitle.Attributes.GetNamedItem("title").Value
                            newtab.Text = newtab.Name
                            TabControl1.Controls.Add(newtab)
                            x = newtab.TabIndex
                            TabControl1.TabPages.Item(x).Controls.Add(newctrl)
                        Next

See if this helps.

newtab.Controls.Add(newctrl) '// add control to new tab.
        TabControl1.Controls.Add(newtab) '// add tab to TabControl.

Still no luck :(

Still no luck :(

There is no way you can make more than 1 textbox (if thats what you are trying to do)
You made 2 controls(textbox and tabpage) and you can't make more than that.

Looks like you calling the same tabpage changing its text on depending on the albumtitle and added the textbox.

Ok, so it wont allow me to add another control because the album array has already called a new control creation?

Would the concept work if I threw the new controls into a .dll and called that in to be populated on each tab?

How many controls do you need to add to every new tab?

The application I'm working on, loads a user defined configuration file for a flash component of a web page, the configuration file is XML and tells the component to load an album.xml file, the idea is to load each individual album.xml file that is definted in the configuration into a new tab, each album has 3 sets of data per album item, the items have no defined limit. Here's an example:

Config.xml:

<menu item_width="65" item_height="65">
      <album title="example1" thumb="images/albums_covers/thumb1.png" path="xml/album1.xml" />
      <album title="example2" thumb="images/albums_covers/thumb2.png" path="xml/album2.xml" />
    </menu>

album1.xml

<item>
		<thumb>gallery/thumbs/album1/1.png</thumb>
		<image>gallery/galleries/album1/1.jpg</image>
		<title>TITLE</title>
		<info><![CDATA[<font color="#FF0000" size="16">TEXT</font>, TEXT.]]></info>
	</item>
	
	<item>
		<thumb>gallery/thumbs/album1/2.png</thumb>
		<image>gallery/galleries/album1/2.jpg</image>
		<title>Douce France</title>
		<info><![CDATA[<font color="#FF0000" size="16">TEXT</font>, TEXT.]]></info>
	</item>

Since my last post I have decided to scratch the idea of creating a new tab per album, instead I will load all of the album titles into a combobox on a single separate tab, from there the user can define the album they wish to load, and populate the tab's body with 3 individual controls per item to allow for easy modification of the album.

So, 3 controls per item, with no set limit, if there needs to be a limit i can probably set one and add another control for "next page" if the albums items exceed the limit?

Your gonna need an array of your controls

Dim lblname As Label() = New Label(10)) {}

creates 10 labels called lblname
then you can use it as
lblname(0).text= Album1.title
lblname(1).text= album2.title

if you don't know the amount of controls you need you can call
say if albumscount comes out to 234

ReDim Preserve lblname(albumscount)

this just made 234 lblname controls


Im not really sure if you can declare at first
Dim lblname as label= new label(ablumscount){}

if an error occurs just do this
Dim lblname as label= new label(1){}

then when you have your albumscount

ReDim Preserve lblname(albumscount)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.