Home All Groups Group Topic Archive Search About

rather basic ?.. brain dead....

Author
20 May 2006 6:21 PM
Aussie Rules
Hi,

i have a list box with a number of items.

I want the user to be able to select a number of items, press the delete
key, and they are delete. The following code does cause an error....

I guess i must be doing it wrong, but can't think how else to go about the
delete (after trapping the delete keydown)

----
Dim indx As clsInspectionTime

For Each indx In lstInspectiontimes.SelectedItems

lstInspectiontimes.Items.Remove(indx)

Next

Author
20 May 2006 6:48 PM
Herfried K. Wagner [MVP]
"Aussie Rules" <nob***@whocares.com> schrieb:
> I want the user to be able to select a number of items, press the delete
> key, and they are delete.

See:

<URL:http://groups.google.de/group/microsoft.public.dotnet.languages.vb/msg/534ed1f2a04ac510>

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
20 May 2006 8:10 PM
Brian Henry
when enumerating a collection, you can not change the enumeration... aka you
cant remove items from it... so you will have to use the .count property of
the selected items collection and move through them one by one until there
is zero items in it... (this is not enumerating, only for each is)

Show quoteHide quote
"Aussie Rules" <nob***@whocares.com> wrote in message
news:u$ktKpDfGHA.3888@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> i have a list box with a number of items.
>
> I want the user to be able to select a number of items, press the delete
> key, and they are delete. The following code does cause an error....
>
> I guess i must be doing it wrong, but can't think how else to go about the
> delete (after trapping the delete keydown)
>
> ----
> Dim indx As clsInspectionTime
>
> For Each indx In lstInspectiontimes.SelectedItems
>
> lstInspectiontimes.Items.Remove(indx)
>
> Next
>
>
>
>
>
>