Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 30th, 2006, 10:24 AM
Authorized User
 
Join Date: Sep 2003
Location: Aurangabad, Maharashtra, India.
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.
Reply With Quote
  #2 (permalink)  
Old June 30th, 2006, 01:21 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
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.
Reply With Quote
  #3 (permalink)  
Old June 30th, 2006, 10:50 PM
Authorized User
 
Join Date: Sep 2003
Location: Aurangabad, Maharashtra, India.
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! :(
Reply With Quote
  #4 (permalink)  
Old July 5th, 2006, 07:46 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
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
Reply With Quote
  #5 (permalink)  
Old July 6th, 2006, 05:19 AM
Authorized User
 
Join Date: Sep 2003
Location: Aurangabad, Maharashtra, India.
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?

Reply With Quote
  #6 (permalink)  
Old July 6th, 2006, 05:21 AM
Authorized User
 
Join Date: Sep 2003
Location: Aurangabad, Maharashtra, India.
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?

Reply With Quote
  #7 (permalink)  
Old July 6th, 2006, 12:25 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
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
Reply With Quote
  #8 (permalink)  
Old July 11th, 2006, 10:45 PM
Authorized User
 
Join Date: Sep 2003
Location: Aurangabad, Maharashtra, India.
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.
Reply With Quote
  #9 (permalink)  
Old October 4th, 2006, 09:07 PM
Registered User
 
Join Date: Oct 2006
Location: , , USA.
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
Reply With Quote
  #10 (permalink)  
Old October 7th, 2006, 01:56 AM
Authorized User
 
Join Date: Sep 2003
Location: Aurangabad, Maharashtra, India.
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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:37 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.