[Originally posted to m.p.d.l.v.windo wsforms.control s but seems to be
v low traffic there, so hope no-one minds if I repost here.]
I'm still struggling to find a way of reordering the items within the
same single listbox with drag and drop. I think I've got the drag
working but it's the drop code I can't figure out. What I have
currently is (with the listbox set to AllowDrop):
Sub MyListBox_Mouse Down(args etc...)
DoDragDrop(MyLi stBox.SelectedI tem, DragDropEffects .Move)
End Sub
Sub MyListBox_DragE nter(args etc...)
e.effect=DragDr opEffects.Move
End sub
Sub MyListBox.DragD rop(args etc...)
'Here's where I'm stuck! Presumably I need:
MyListBox.Items .Insert(???, MyListBox.Selec tedItem)
End Sub
Obviously I need some code in the last sub to insert the
currently-selected item (ie the one picked up by the Drag) immediately
before the item over which the mouse is currently hovering. But how
can I get the index of this item and then drop the selected item.
Possibly/probably I need to explicitly delete the source item?
Thanks for any help.
JGD
v low traffic there, so hope no-one minds if I repost here.]
I'm still struggling to find a way of reordering the items within the
same single listbox with drag and drop. I think I've got the drag
working but it's the drop code I can't figure out. What I have
currently is (with the listbox set to AllowDrop):
Sub MyListBox_Mouse Down(args etc...)
DoDragDrop(MyLi stBox.SelectedI tem, DragDropEffects .Move)
End Sub
Sub MyListBox_DragE nter(args etc...)
e.effect=DragDr opEffects.Move
End sub
Sub MyListBox.DragD rop(args etc...)
'Here's where I'm stuck! Presumably I need:
MyListBox.Items .Insert(???, MyListBox.Selec tedItem)
End Sub
Obviously I need some code in the last sub to insert the
currently-selected item (ie the one picked up by the Drag) immediately
before the item over which the mouse is currently hovering. But how
can I get the index of this item and then drop the selected item.
Possibly/probably I need to explicitly delete the source item?
Thanks for any help.
JGD
Comment