Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
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
 
Old June 30th, 2006, 10:24 AM
Authorized User
 
Join Date: Sep 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to vb_programmer Send a message via Yahoo to vb_programmer
Default 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.
 
Old June 30th, 2006, 01:21 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

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.
 
Old June 30th, 2006, 10:50 PM
Authorized User
 
Join Date: Sep 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to vb_programmer Send a message via Yahoo to vb_programmer
Default

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! :(
 
Old July 5th, 2006, 07:46 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old July 6th, 2006, 05:19 AM
Authorized User
 
Join Date: Sep 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to vb_programmer Send a message via Yahoo to vb_programmer
Default

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?

 
Old July 6th, 2006, 05:21 AM
Authorized User
 
Join Date: Sep 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to vb_programmer Send a message via Yahoo to vb_programmer
Default

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?

 
Old July 6th, 2006, 12:25 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old July 11th, 2006, 10:45 PM
Authorized User
 
Join Date: Sep 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to vb_programmer Send a message via Yahoo to vb_programmer
Default

Yeh, I tried it and it worked fine. Thanks.
 
Old October 4th, 2006, 09:07 PM
Registered User
 
Join Date: Oct 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old October 7th, 2006, 01:56 AM
Authorized User
 
Join Date: Sep 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to vb_programmer Send a message via Yahoo to vb_programmer
Default

Thanks! Certainly a valuable tip.





Similar Threads
Thread Thread Starter Forum Replies Last Post
drag and drop multiple controls at runtime ramakishore VB How-To 5 November 2nd, 2006 12:56 PM
Drag and drop vpinhao Beginning VB 6 0 September 11th, 2006 01:33 PM
Drag/Drop bmains Javascript 1 September 22nd, 2004 07:29 PM
drag and drop to multiple text boxes gbuller VB.NET 5 September 6th, 2004 09:55 PM
Drag and drop Clive Astley Access 2 August 15th, 2003 12:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.