Re: listbox multiselect madness by Norman
Norman
Sat Nov 12 11:38:52 CST 2005
If you read .NET document/Visual Studio help on
System.Windows.Forms.ListBox, you can find ListBox.SelectedItems or
ListBox.SelectedIndices is what you want. Here is the excerpt from .NET
document:
For a multiple-selection ListBox, this property returns a collection
containing all items that are selected in the ListBox. For a
single-selection ListBox, this property returns a collection containing a
single element containing the only selected item in the ListBox. For more
information on how to manipulate the items of the collection, see
ListBox.SelectedObjectCollection.
The ListBox class provides a number of ways to reference selected items.
Instead of using the SelectedItems property to obtain the currently selected
item in a single-selection ListBox, you can use the SelectedItem property.
If you want to obtain the index position of an item that is currently
selected in the ListBox, instead of the item itself, use the SelectedIndex
property. In addition, you can use the SelectedIndices property if you want
to obtain the index positions of all selected items in a multiple-selection
ListBox.
"chauncy" <chauncy_the_dog@hotmail.com> wrote in message
news:OMgoay65FHA.4036@TK2MSFTNGP11.phx.gbl...
> Hey all,
>
> On a windows form, I have a databound listbox with multiselect. All I want
> to is spin through the selected items and find the value for each.
>
> I've been everywhere and still haven't found a way to do this.
> Please don't show me thee xample with listitem. There are no listitems
> in windows forms.
>
> Little help...
>