Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15908

[RESOLVED] Moving listbox items up/down using mouse....

$
0
0
Simple little test:

Code:

Option ExplicitDim list1IndexA As String, list1IndexB As String, list1IndexC As String
Private Sub Form_Load()
    List1.AddItem "SAM"
    List1.AddItem "JOHN"
    List1.AddItem "FRANK"
    List1.AddItem "BILL"
    List1.AddItem "JAMES"
End Sub
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    list1IndexA = List1.ListIndex
End Sub
Private Sub List1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    list1IndexB = List1.List(list1IndexA)
    list1IndexC = List1.ListIndex
    List1.RemoveItem (list1IndexA)
    List1.AddItem list1IndexB, list1IndexC
End Sub

When running, I move items up or down the listbox (reorder kinda thing) using the mouse (not a command button). After the first time moving something, the item BELOW the moved item is highlighted in the listbox. (rather it stay highlighted).

Second problem--if I simply click on an item, the item ABOVE what the one I clicked on is SORTA highighted---I mean, the dashed rectangle shows that item above as being 'selected'.

So, what I am looking for is how to have my selected listbox item remain highlighted, either when I move an item, OR when I simply click on one.

(the listbox in question in one of my programs might have up to a couple hundred entries. I currently use (but want to uncode (decode???)) a right-mouseclick on the listbox to move an item to the SECOND position in the list. But I would rather just 'go get an item' and move it where I want it with the mouse.)

Viewing all articles
Browse latest Browse all 15908

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>