Advertisement
4_2005-2006 Coding Standards #160642

Listbox Item •move• Multiselect compatable

Planning to use (a) listbox in your program? Maybe loading database data or MP3 Playlist. With these two functions (including the normal remove function) you are able to move items (compatable to Multiselect) up and down. I may be wrong but I haven't seen these two function on PSC so that's why I decided to posted these functions. Find it useful??? ***Please Vote***

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
'''ALL THESE FUNCTIONS ARE COMPATABLE TO MULTISELECT'''
'Moving Listbox item down
Public Function LstMoveDown(lst As ListBox)
Dim i
Dim strString As String
Dim strItemData As Long
For i = lst.ListCount - 2 To 0 Step -1
 If (lst.Selected(i) = False) Then GoTo skip
 strString = lst.List(i)
 strItemData = lst.ItemData(i)
 lst.RemoveItem (i)
 If i < lst.ListCount - 1 Then
  lst.AddItem strString, i + 1
  lst.ItemData(i + 1) = strItemData
  lst.Selected(i + 1) = True
 Else
  lst.AddItem strString
  lst.Selected(lst.ListCount - 1) = True
 End If
skip:
Next i
End Function
'Moving Listbox item up
Public Function LstMoveUp(lst As ListBox)
Dim i
Dim strString As String
Dim strItemData As Long
For i = 0 To lst.ListCount - 1
 If (lst.Selected(i) = False) Or i = 0 Then GoTo skip
 strString = lst.List(i)
 strItemData = lst.ItemData(i)
 lst.RemoveItem (i)
 lst.AddItem strString, i - 1
 lst.ItemData(i - 1) = strItemData
 lst.Selected(i - 1) = True
skip:
Next i
End Function
'Removing Listbox items
Public Function LstRemoveItem(lst As ListBox)
Dim i
For i = lst.ListCount - 1 To 0 Step -1
 If (lst.Selected(i) = True) Then
 lst.RemoveItem (i)
 End If
Next i
End Function
Original Comments (3)
Recovered from Wayback Machine