Jordan Moffat
Jordan Moffat

Reputation: 337

Adding items from list to listbox control

Had a scout around, but can't find anything that works.

I have a list of an undetermined size, and I'm trying to display it in a list box List<String> urls

Items are dynamically added to the list by doing urls.Items.Add(string)

I've tried doing lstURLS.Items.Add(urls), and it returns Collections in the list box.

I've also tried lsturls.Datasource = urls but it doesn't recognise that as being valid code.

Is there an easy method of doing this?

Upvotes: 0

Views: 49

Answers (1)

the-nick-wilson
the-nick-wilson

Reputation: 616

You'll need a for each loop:

for each (string s in urls) {lstUrls.Items.Add(s);}

I think this is what you're looking for?

Upvotes: 1

Related Questions