Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
using ArrayList to create dynamic tabcontrol pages
Barbulescu Mihai
Jan 30 2009 12:33 PM
9k
Reply
I have the following function reading XML file:
Function ReadProductsCategories(ByVal XMLFile As String) As ArrayList
Dim ReaderArray As New ArrayList
Dim Reader As XmlTextReader = New XmlTextReader(XMLFile)
Do While (reader.Read())
Select Case reader.NodeType
Case XmlNodeType.Text
'Store values in the arraylist container
ReaderArray.Add(Reader.Value)
End Select
Loop
'Return the arraylist container
Return ReaderArray
End Function
The following Sub is using it:
Private Sub LoadAllProductsCategories()
Dim i As Integer
Dim ItemList As New ArrayList
Dim AllProdTabPage As New TabPage
ItemList = ReadProductsCategories("allprodcat.xml")
For i = 0 To ItemList.Count - 1
AllProdTabPage.Name = "tab" & ItemList.Item(i)
AllProdTabPage.Text = ItemList.Item(i)
TabControl2.Controls.Add(AllProdTabPage)
Next
End Sub
The problem is that the first tabpage text is replaced with the last tabpage text. In this way I get the last tabpage 2 times, in the first position (where there should be completely other tabpage, the real one, the first one) and in the last position (correct)
Any ideea why I get this problem ? I have tested the XML reading by displaying messageboxes with each arraylist element and all is fine, the problem is when actually creating the tabpages.
Looking forward to your support on this one!
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
two dimensional array