J
John Dann
[Originally posted to m.p.d.l.v.windowsforms.controls 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_MouseDown(args etc...)
DoDragDrop(MyListBox.SelectedItem, DragDropEffects.Move)
End Sub
Sub MyListBox_DragEnter(args etc...)
e.effect=DragDropEffects.Move
End sub
Sub MyListBox.DragDrop(args etc...)
'Here's where I'm stuck! Presumably I need:
MyListBox.Items.Insert(???, MyListBox.SelectedItem)
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_MouseDown(args etc...)
DoDragDrop(MyListBox.SelectedItem, DragDropEffects.Move)
End Sub
Sub MyListBox_DragEnter(args etc...)
e.effect=DragDropEffects.Move
End sub
Sub MyListBox.DragDrop(args etc...)
'Here's where I'm stuck! Presumably I need:
MyListBox.Items.Insert(???, MyListBox.SelectedItem)
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