Simple question: copy ArrayList to ListBox items

Simple question: copy ArrayList to ListBox items

Post by Jim Owe » Fri, 14 Mar 2003 03:21:49



How do I copy the contents of an ArrayList into a ListBox?

--
- Jim Owen
206-501-6936

 
 
 

Simple question: copy ArrayList to ListBox items

Post by Victor Garcia Aprea [MVP » Fri, 14 Mar 2003 04:05:36


What type is the ArrayList holding? Basically you would need to iterate the
array list, and for each item calling Items.Add on the ListBox (I'm assuming
you want to add items to a listbox based on the items on the array).

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.
--
Learning ASP.NET, C# and VS.NET? Look at this book:
Beginning C# Web Applications with Visual Studio .NET
http://www.amazon.com/exec/obidos/ASIN/1861007329/laplatayacom


Quote:> How do I copy the contents of an ArrayList into a ListBox?

> --
> - Jim Owen
> 206-501-6936


 
 
 

Simple question: copy ArrayList to ListBox items

Post by John Saunder » Fri, 14 Mar 2003 04:07:24


ListBox.DataSource = arraylist
ListBox.DataTextField = "fieldToShowUp"
ListBox.DataValueField = "fieldForTheValues"

--
John Saunders
Internet Engineer


Quote:> How do I copy the contents of an ArrayList into a ListBox?

> --
> - Jim Owen
> 206-501-6936

 
 
 

Simple question: copy ArrayList to ListBox items

Post by Jim Owe » Fri, 14 Mar 2003 07:59:47


So, my ArrayList is just holding strings, so what do I name as the fields in
"fieldToShowUp" and "fieldForTheValues"? I haven't named any fields in my
source ArrayLists....

--
- Jim Owen
206-501-6936

> ListBox.DataSource = arraylist
> ListBox.DataTextField = "fieldToShowUp"
> ListBox.DataValueField = "fieldForTheValues"

> --
> John Saunders
> Internet Engineer



> > How do I copy the contents of an ArrayList into a ListBox?

> > --
> > - Jim Owen
> > 206-501-6936

 
 
 

Simple question: copy ArrayList to ListBox items

Post by John Saunder » Fri, 14 Mar 2003 08:37:12


I haven't done simple strings for a while, but I don't think you'll have to
name anything. I think that in this case, it just takes the value of the
string as both display and value.

--
John Saunders
Internet Engineer


> So, my ArrayList is just holding strings, so what do I name as the fields
in
> "fieldToShowUp" and "fieldForTheValues"? I haven't named any fields in my
> source ArrayLists....

> --
> - Jim Owen
> 206-501-6936


> > ListBox.DataSource = arraylist
> > ListBox.DataTextField = "fieldToShowUp"
> > ListBox.DataValueField = "fieldForTheValues"

> > --
> > John Saunders
> > Internet Engineer



> > > How do I copy the contents of an ArrayList into a ListBox?

> > > --
> > > - Jim Owen
> > > 206-501-6936