Drag and drop from listview to listbox more than one line at a time

aw48

Active member
Joined
Feb 9, 2013
Messages
36
Location
Germany
Programming Experience
10+
hi,
from listview I want to move a number of lines to a listbox
here' s the listview's mouse_down :
        private void lvLib_MouseDown(object sender, MouseEventArgs e)
        {
            ListView lv = (ListView)sender;
         ListViewHitTestInfo info = lv.HitTest(e.X, e.Y);
            if (info.Item == null) return;

            if (info.Item.Selected) {
                DragDropFormat = DataFormats.Serializable;
                DoDragDrop(lv.SelectedItems,DragDropEffects.Copy);
            }
        }

if user clicks a selected item I will call DoDragDrop otherwise just select the item
that works, but from here on nothing happens
neither lv DragLeave nor lbx DragDrop respond.
DoDragDrop obviously has some dificulty with DataFormats.Serializable and/or lv.SelectedItems.
I did the same with a string and DataFormats.Text and that was ok.
am I missing something ? any ideas ?
I am using VS10
thanks in advance
franz
 
Last edited by a moderator:
See Drag, Drop and Move Multiple Items from a ListView to a TreeView control | DotNetCurry
Here's the essence of that example:
private void listView1_ItemDrag(object sender, ItemDragEventArgs e)
{
    listView1.DoDragDrop(listView1.SelectedItems, DragDropEffects.Move);
}
 
Back
Top Bottom