473,486 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 7934
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
42671
by: Filips Benoit | last post by:
Dear All, I have code that selects - find and select - 1 item in a large listbox. This works Ok but most of the time the selected item isn't visible without scrolling down manualy. Is this...
1
1594
by: Sally | last post by:
In a simple multiselect listbox, what is the code for the AfterUpdate event to determine if the item clicked on was selected or deselected? Thanks! Sally
5
3842
by: Silvia | last post by:
Hi I have a listbox in a form which has been set on multiselect simple. If I select some of the items on the list on day1, save and exit, and return on day2, the items I selected on day1 do not...
1
7858
by: jez123456 | last post by:
Hi, I have a windows form with a listbox control. My code all works correctly when deleting an item from the listbox except the last item. I get the following message when trying to delete the...
0
1422
by: antonyliu2002 | last post by:
I am not new to programming, but I am new to VB .NET. I have a multiselect listbox like this: Please select your favorite fruit: Apple Banana Coconut Date
5
2417
by: John Veldthuis | last post by:
My code works perfectly 100% when adding items to my ArrayList and updating the listbox. Works perfectly when deleting an item in the ArrayList when it is not the last entry but if it is the last...
1
1111
by: Bruce F | last post by:
I have a multiselect ListBox and I want to determine which items are selected. I don't want to use "SelectedItems" but want to loop through all items and check if selected or not. What I want...
1
1436
by: BillAtWork | last post by:
Hi, I have a listbox (in a user control) which has items add/removed via javascript (i.e. an "add item" link which uses a popup selection screen to add items and a "remove item" link which deletes...
3
6279
by: peter.mosley | last post by:
I've tried googling for the answer to this problem, without any luck. I'm sure the truth must be out there somewhere! I have a multiselect listbox populated with many items (set by the RowSource...
0
7094
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6839
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7305
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4863
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3066
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
259
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.