 |
| Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 30th, 2006, 10:24 AM
|
|
Authorized User
|
|
Join Date: Sep 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Please Help me with Drag-n-Drop of multiple items
Hello!
I'm facing a problem with Listview Drog and Drop of multiple items from one listview to another listview. When I try to Drag only one single item, the item is dragged without any problem. However, when the multiple selected items are dragged, the Listview on which the items are dropped, receives information about only one item and not all selected items. The item, about which the information is received, is the same on which I click and hold mouse to start drag action. So, it looks like even though multiple items are selected in a listview, while executing the Drag-Drop action, listview treats it as single item selected!
Is this a default behavior of Listview or am I missing/doing anything wrong? Any work-around for this (seems like default) behavior of Listview? I searched for it and got a code example at http://btmtz.mvps.org/listview/ where the author has demonstrated Drag-Drop of multiple items. However, the code is specifically restricted to re-arranging items within same Listview and the information is transported via Drag-Drop to another Listview, upon which the items are dropped.
Waiting for your valuable reply ...
Regards,
Ruturaj.
|
|

June 30th, 2006, 01:21 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
I'm sure you are going to have to add code that is triggered by the 'drop' action of the destination control to then go and check whether multiple items are selected in the source control, and, if so, copy each additional item through code.
|
|

June 30th, 2006, 10:50 PM
|
|
Authorized User
|
|
Join Date: Sep 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by BrianWren
I'm sure you are going to have to add code that is triggered by the 'drop' action of the destination control to then go and check whether multiple items are selected in the source control, and, if so, copy each additional item through code.
|
Yeh, I think that's the only way because it looks like Data object is totally blind to this aspect of Listview control. Basically I was expecting some string array or something that sort of thing; but this seems to be impossible! :(
|
|

July 5th, 2006, 07:46 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I solved the problem storing the selected ListView items in a Collection before I start the dragging operation. In the drop event, I use the collection to find the items to be dropped
|
|

July 6th, 2006, 05:19 AM
|
|
Authorized User
|
|
Join Date: Sep 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by marcostraf
I solved the problem storing the selected ListView items in a Collection before I start the dragging operation. In the drop event, I use the collection to find the items to be dropped
|
In this case, how you deal with SubItems?
|
|

July 6th, 2006, 05:21 AM
|
|
Authorized User
|
|
Join Date: Sep 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by marcostraf
I solved the problem storing the selected ListView items in a Collection before I start the dragging operation. In the drop event, I use the collection to find the items to be dropped
|
Also, when the Drop action is completed then how do you clear your Collection? I guess Set colObj = Nothing will do it for us, right?
|
|

July 6th, 2006, 12:25 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
yes, after the drop operation setting the collection to nothing will clear it
if you store in the collection the key or the index of the selected item, you get the sub items just using the SubItem method
|
|

July 11th, 2006, 10:45 PM
|
|
Authorized User
|
|
Join Date: Sep 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yeh, I tried it and it worked fine. Thanks.
|
|

October 4th, 2006, 09:07 PM
|
|
Registered User
|
|
Join Date: Oct 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Why dont you try to call the "DoDragDrop" of the listview in the ItemDrag event handler
listview1_ItemDrag(object sender, ItemDragEventArgs e)
{
listview1.DoDragDrop(listview1.SelectedItems, DragDropEffects.Move);
}
in the dragdrop event of the receiving listview, simply typecast the object back to "ListView.SelectedListViewItemCollection"
and we are done.
Mayukh
|
|

October 7th, 2006, 01:56 AM
|
|
Authorized User
|
|
Join Date: Sep 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks! Certainly a valuable tip.
|
|
 |