Drag & Drop Multiple Items between ListBoxes

B

BVM

Hi, All:

Do you know how to do drag & drop multiple items between listboxes? I can only do with single selection.

Thank you,

Dennis Huang
 
V

Vijay

Not very different from single item, in this case your source becomes a collection of items rather than just a single item...in which you will send all selecteditems from the listbox.. This is provided you have enabled multi select in the list box

Vijay
Hi, All:

Do you know how to do drag & drop multiple items between listboxes? I can only do with single selection.

Thank you,

Dennis Huang
 
B

BVM

Thanks, Vijay. I have done what you said. The problem is I cannot drag multi-selected items. It seems DoDragDrop does not work when list items are multiple selected.

Dennis Huang
Not very different from single item, in this case your source becomes a collection of items rather than just a single item...in which you will send all selecteditems from the listbox.. This is provided you have enabled multi select in the list box

Vijay
Hi, All:

Do you know how to do drag & drop multiple items between listboxes? I can only do with single selection.

Thank you,

Dennis Huang
 
V

VJ

Dennis..

Ok let me explain a little bit better,

lstSource.DoDragDrop(sender, DragDropEffects.All);

When you do the above.. your "sender" here is the object i.e Listbox, which will have multiple selected items.. from selectedItems property... , this is going to be available in the destination, which you can drop..., so in destination..

ListBox lstSource = (ListBox)(e.Data.GetData(typeof(ListBox)));
lstSource.SelectedItems; //<-- has source all selected items;

I am not sure what is not working.. can you give a piece of code outline.. ? or maybe be you are looking for showing the Drag of multiple items.. in which case you will have to have a icon or image for the cursor that can show this effect...

Vijay

Thanks, Vijay. I have done what you said. The problem is I cannot drag multi-selected items. It seems DoDragDrop does not work when list items are multiple selected.

Dennis Huang
Not very different from single item, in this case your source becomes a collection of items rather than just a single item...in which you will send all selecteditems from the listbox.. This is provided you have enabled multi select in the list box

Vijay
Hi, All:

Do you know how to do drag & drop multiple items between listboxes? I can only do with single selection.

Thank you,

Dennis Huang
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top