G
Guest
I'm attempting to get an arraylist to display in a Listbox (listbox2). The
arraylist is created from selections in a different listbox (listbox1). The
1st listbox has a selection mode of MultiExtended. Once the selection has
been made in the 1st ListBox, the user clicks on a button to generate the
arraylist using the values selected. Then click a second button to display
the arraylist contents to ListBox2. There are no errors, but all I get in the
second ListBox is System.Data.DataRowView. I do not want to convert the
arraylist to a string as I want to eventually enter the values in the
arraylist in a database.
Here's the code that I have.
'This is in the form's load event, to populate the 1st ListBox
ListBox1.DataSource = DsPlayerStats1.tblPlayers
ListBox1.DisplayMember = "Expr1"
ListBox1.SelectionMode = SelectionMode.MultiExtended
'Now the code for the 1st button to add the selected items to the arraylist
Private Sub btnAddPlayer_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAddPlayer.Click
TourneyField.AddRange(ListBox1.SelectedItems)
End Sub
'Now the code to display the contents of the arraylist in the 2nd ListBox.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
For Each pl In TourneyField
ListBox2.Items.Add(pl)
Next
TourneyField.Clear()
End Sub
Any suggestions, or help would be appreciated.
Cheers,
Steve
arraylist is created from selections in a different listbox (listbox1). The
1st listbox has a selection mode of MultiExtended. Once the selection has
been made in the 1st ListBox, the user clicks on a button to generate the
arraylist using the values selected. Then click a second button to display
the arraylist contents to ListBox2. There are no errors, but all I get in the
second ListBox is System.Data.DataRowView. I do not want to convert the
arraylist to a string as I want to eventually enter the values in the
arraylist in a database.
Here's the code that I have.
'This is in the form's load event, to populate the 1st ListBox
ListBox1.DataSource = DsPlayerStats1.tblPlayers
ListBox1.DisplayMember = "Expr1"
ListBox1.SelectionMode = SelectionMode.MultiExtended
'Now the code for the 1st button to add the selected items to the arraylist
Private Sub btnAddPlayer_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAddPlayer.Click
TourneyField.AddRange(ListBox1.SelectedItems)
End Sub
'Now the code to display the contents of the arraylist in the 2nd ListBox.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
For Each pl In TourneyField
ListBox2.Items.Add(pl)
Next
TourneyField.Clear()
End Sub
Any suggestions, or help would be appreciated.
Cheers,
Steve