Why do you manually add items to ListBox2? Why not databind it, like
ListBox2.DataSource = TourneyField. Keep in mind that you don't want to
TourneyField.Clear() anymore then. Just work on TourneyField's values
instead of manipulating the listbox. I find it also helpfull to check
how TourneyField looks like in memory, so you could try that aswell and
see if it is correct there. Also, try see if settings the DisplayMember
property helps.
Michel van den Berg
[quoted text, click to view] Fieldmedic wrote:
> 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
>
>
>
>
>
I tired the ListBox2.DataSource = TourneyField and get the same stuff
displayed in the listbox (System.Data.DataRowView). As for the display member
portion, I'm at a loss since I'm dealing with an arraylist and not an actual
dataset. Any suggestions?
Regards,
Steve
[quoted text, click to view] "Michel van den Berg" wrote:
> Why do you manually add items to ListBox2? Why not databind it, like
> ListBox2.DataSource = TourneyField. Keep in mind that you don't want to
> TourneyField.Clear() anymore then. Just work on TourneyField's values
> instead of manipulating the listbox. I find it also helpfull to check
> how TourneyField looks like in memory, so you could try that aswell and
> see if it is correct there. Also, try see if settings the DisplayMember
> property helps.
>
> Michel van den Berg
>
> Fieldmedic wrote:
> > 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
> >
> >
> >
> >
> >
> >
Don't see what you're looking for? Try a search.