JohanE
JohanE

Reputation: 143

Drag and drop multiple items between listboxes using windows forms

I want to do drag and drop between 2 listboxes, but be able to select multiple items in one listbox, and drag those across to the other listbox. I need to make sure I don't accidentally "drop" them back on the source listbox. I did this in Borland Builder C++ successfully, but can only drag and drop one item at a time using the C# methods. I have gone through all the possibilities here, but none of them gives me a nudge in the right direction. In BCB the DragDrop method had references to the Sender and Source objects, which you could use to determine where the item came from. You could then iterate through the selected list and move them across from source to destination as needed. Is there anything similar available in C# using windows forms, not WPF?

I hope I make some sense in this question!

Upvotes: 1

Views: 1057

Answers (1)

President Camacho
President Camacho

Reputation: 1910

Set the listbox property SelectionMode to SelectionMode.MultiExtended. To be able to select multiple items.

listBox.SelectionMode = SelectionMode.MultiExtended;

Upvotes: 1

Related Questions