I have multiple listviews on a form (WinForms). List items can be dragged to other listviews. Is there a way to cancel a single item within the dragged items list? The target listview determines whether or not a single item can be dropped there. I'd prefer a solution that will accept all items that are allowed, and reject those that are not. Insights appreciated.

Perhaps you could manipulate the Tag property of the ListViewItem. Don't no if this will work, never tried it myself, but if I would, I would try this as my first option.

The problem is not identifying which item to allow, but how to cancel it's drag/drop event.

Is it not possible in, the drag/drop events, to check if some flag is set in the Tag object and act accordingly?

The easiest way is to set up a proxy list.

In your drag drop event, move the items that you've "dragged" into a secondary list and cancel the entire dragdrop event.

Watch this list for changes. When you detected changes to this list, pull out any you wish to "cancel". Anything you want to keep add to the new ListView and remove from the old ListView manually. You should be able to find them using Equals as they should be object references though I can't confirm this.

This is just an idea, unfortunately dragdrop doesn't do what you want to do natively and this is the best "workaround" I can think of in 2 minutes.

Edited 3 Years Ago by Ketsuekiame

This question has already been answered. Start a new discussion instead.