ListBox

P

Peter Kirk

Is it correct that in a ListBox control which is multiple selection, I have
to manually iterate through all items to find out which ones are selected?
There is no "ListItem[] GetSelectedItems()" or something like that?
 
S

Scott Mitchell [MVP]

Peter said:
Is it correct that in a ListBox control which is multiple selection, I have
to manually iterate through all items to find out which ones are selected?
There is no "ListItem[] GetSelectedItems()" or something like that?

Correct. You can use .SelectedItem to get the *first* such selected
item, but if you want them all you need to enumerate the Items
collection and check the Selected property of each ListItem.

Of course, you could always extend the ListBox class and provide a
read-only property called SelectedItems that returned an array of
ListItems...

Same deal in 2.0, btw...

Happy Programming!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,142
Messages
2,570,817
Members
47,363
Latest member
eitamoro

Latest Threads

Top