Question : Speed up selecting all items in list box.

I asked this question about a month ago but didn't really get an answer.  Thought I'd try again:

Is there a faster way to select all items in an extended multiselect listbox with a high ListCount than?

Me.Painting = False
For i = 0 To ProcedureList.ListCount - 1
    ProcedureList.Selected(i) = True
Next i
Me.Painting = True

When ProcedureList.ListCount is higher than ~2000, the above procedure takes 10+ seconds.  

Clicking on the first item, scrolling to the bottom and shift clicking on the last item selects all items almost instantly so I tried to simulate that in code.  These attempts did not work but maybe they will give someone an idea:

ProcedureList.SetFocus
hWndSB = GetFocus
ProcedureList.ListIndex = 0
SendKeys " "
ProcedureList.ListIndex = ProcedureList.ListCount - 1
SendKeys "+ "

ProcedureList.SetFocus
hWndSB = GetFocus
ProcedureList.ListIndex = 0
LngThumb = MakeDWord(SB_THUMBPOSITION, CInt(ProcedureList.ListCount - 1))
lngRet = SendMessage(hWndSB, WM_VSCROLL, LngThumb, 0&)
SendKeys "+ "

Answer : Speed up selecting all items in list box.

Sorry, no other way.  The ItemsSelected collection for a listbox is a hidden, read-only collection.  The only way to alter it is by mouse-click or spacebar.  I would not recommend trying to use SendKeys - it's dangerous to depend on it to work properly in all situations - but you'll need to make sure the listbox's MultiSelect property is set to Extended if you want to try them anyways.
Random Solutions  
 
programming4us programming4us