ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multi-select listbox - mousedown event (https://www.excelbanter.com/excel-programming/444429-multi-select-listbox-mousedown-event.html)

Greg Lovern

Multi-select listbox - mousedown event
 
With a multi-select listbox, when the mousedown event fires when a
user clicks one of the boxes, the Selected property reports the
selection state of the list BEFORE the mouseclick. Since I don't know
what box was clicked, I don't know the selection state of any list
items when that event fires; all I know is that the selection state
one of the list items is different than reported by the Selected
property.

The Enter event also fires if the listbox didn't already have focus,
but it has the same problem.

No other events fire when the user clicks one of the boxes, as far as
I can tell.

Is there any way to get the true selection state of the list when the
user clicks one of the boxes in the list?


Thanks,

Greg

GS[_2_]

Multi-select listbox - mousedown event
 
After serious thinking Greg Lovern wrote :
With a multi-select listbox, when the mousedown event fires when a
user clicks one of the boxes, the Selected property reports the
selection state of the list BEFORE the mouseclick. Since I don't know
what box was clicked, I don't know the selection state of any list
items when that event fires; all I know is that the selection state
one of the list items is different than reported by the Selected
property.

The Enter event also fires if the listbox didn't already have focus,
but it has the same problem.

No other events fire when the user clicks one of the boxes, as far as
I can tell.

Is there any way to get the true selection state of the list when the
user clicks one of the boxes in the list?


Thanks,

Greg


Try this...

Private Sub ListBox1_Change()
Debug.Print ListBox1.ListIndex
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc



Greg Lovern

Multi-select listbox - mousedown event
 

Doh! Thanks, and pardon my brain fart! :-)

Greg


All times are GMT +1. The time now is 01:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com