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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listboxes appear to be linked

Status
Not open for further replies.

drluggo

Programmer
Jan 14, 2003
39
US
I have two listbox controls on the same form that I have populated using an arraylist created from an xml file. When I execute the form, the information appears in the list boxes as it should; however, when I make a selection in one of the list boxes, the selected value in the other changes.

Also, When I go to print out the selected values using:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Label3.Text = "Creating Test For " & ListBox1.SelectedValue _
& ":" & ListBox2.SelectedValue & ". Please Wait..."

Label3.Visible = True

End Sub

I get the selected value of the Listbox2 in both inserted places.

When I created these on the form I did not copy paste one from the other, I dragged two new listboxes onto the windows form.

Other things to note. I did populate the two listboxes using the same arraylist object after clearing it using:

xmlDoc.Load("../xml/BatchConfig.xml")
xmlNdList = xmlDoc.GetElementsByTagName("Unit")

For i = 0 To xmlNdList.Count - 1

arlAL.Add(xmlNdList.Item(i).Attributes("Id").Value)

Next

ListBox1.DataSource = arlAL

arlAL.Clear()

xmlNdList = xmlDoc.GetElementsByTagName("Phase")

For i = 0 To xmlNdList.Count - 1

arlAL.Add(xmlNdList.Item(i).Attributes("Id").Value)

Next

ListBox2.DataSource = arlAL



What gives?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top