VBNotebook Home | Functions | Set List Caret
This routine allows you to change the List Caret to a particular item in a multi-select Listbox without having to set the ListIndex property to that item.
First, in General|Declarations, include the following...
__________________________________________________________________________________________
Private Const LB_SETCURSEL = &H186
Private Declare Function SendMessageByNum Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
__________________________________________________________________________________________
And the routine itself....
__________________________________________________________________________________________
Sub SetListCaretIndex(lstList As ListBox, ByVal iIndex As Integer)
Dim nRet As Long
nRet = SendMessageByNum(lstList.hwnd, LB_SETCARETINDEX, iIndex, True)
End Sub
__________________________________________________________________________________________
Copyright 2000-2005, J. Frank Carr