469,924 Members | 1,418 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,924 developers. It's quick & easy.

How to get the last selected item in multiselect ListBox?

Anyone knows if there is some kind of property or function that will
return the last selected/deselected item/index in a multiselect
ListBox? SelectedIndex will point to first index in the
SelectedIndices collection, so this is a dead end. My solution so far
is to override the mouse click and key pressed events. However, since
arrow up/down seems to keep a record of the item that currently has
focus somehow, I would believe this information is stored somewhere.
Any help is appreciated since I can't seem to figure this out without
tending to overkill solutions.

- Peder -
Nov 16 '05 #1
2 7696
A quick thought -- if we can query the control to get the value of the
number of items in the ListBox we can get the value of the last item
in its collection. That should be in the documentation.

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

"Peder Y" <py*****@ec.auckland.ac.nz> wrote in message
news:10**************************@posting.google.c om...
Anyone knows if there is some kind of property or function that will
return the last selected/deselected item/index in a multiselect
ListBox? SelectedIndex will point to first index in the
SelectedIndices collection, so this is a dead end. My solution so far
is to override the mouse click and key pressed events. However, since
arrow up/down seems to keep a record of the item that currently has
focus somehow, I would believe this information is stored somewhere.
Any help is appreciated since I can't seem to figure this out without
tending to overkill solutions.

- Peder -

Nov 16 '05 #2
Sure, but a _collection_ doesn't support that property. Items.Count
gets the number of items. I've looked high and low for an answer to
this question, and it doesn't seem to be answered anywhere. And "last
item" can be a bit obscure. There is a subcollection called
SelectedItems/Indices, but the item with focus does not necessarily
have to be in this collection. For example one can select a range of
items, then deselect one of them. The deselected one will have focus,
but won't be selected.

This is a tough nut!

- Peder -
"clintonG" <csgallagher@RE************@metromilwaukee.com> wrote in message news:<uE*************@TK2MSFTNGP11.phx.gbl>...
A quick thought -- if we can query the control to get the value of the
number of items in the ListBox we can get the value of the last item
in its collection. That should be in the documentation.

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

"Peder Y" <py*****@ec.auckland.ac.nz> wrote in message
news:10**************************@posting.google.c om...
Anyone knows if there is some kind of property or function that will
return the last selected/deselected item/index in a multiselect
ListBox? SelectedIndex will point to first index in the
SelectedIndices collection, so this is a dead end. My solution so far
is to override the mouse click and key pressed events. However, since
arrow up/down seems to keep a record of the item that currently has
focus somehow, I would believe this information is stored somewhere.
Any help is appreciated since I can't seem to figure this out without
tending to overkill solutions.

- Peder -

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by jez123456 | last post: by
1 post views Thread by Bruce F | last post: by
1 post views Thread by BillAtWork | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.