Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drag And Drop

Status
Not open for further replies.

DANY

Programmer
Mar 13, 2001
4
US
Hello to all,

I would like to know how to multi select items in a ListView and drag it accross to a TreeView in any folders.
Please help if you can. I am just learning VB6.

Thanks
 
OK, the general procedure is to change the DragMode property of the source control (a listview, in your case) to "Automatic". You can also set the DragIcon property to a nice icon at the same time.

When the user drags their mouse (which now looks like the icon you chose), that control's DragOver event fires. If that control is able to accept the drop, you'd change the drag icon to one that indicates to the user that they can let go of the mouse button now (using the Source.DragIcon parameter). One way for the control to determine if the drop is OK is to look at the Source parameter, which is a reference to the control where the drop started. You can check the source control's name property (or something similar) to see if you want to indicate it's OK to drop.

When the user lets go over a control, that control's DragDrop event gets fired. This has a similar set of parameters to the DragOver event -- namely the Source parameter. The tricky part is getting the data from the source control. The easiest way is when the drag operation begins is to store the data in a module-level variable (maybe a collection, maybe a user-defined structure). When the DragDrop event fires, you'd verify the Source control again, and then copy the values from the module-level variable into your new control.

Hope this gets you started.

Chip H.
 
Hi Chip,

I tried what you said but I am not getting nothing. Can you share some codes. I think it required more steps along the line.

thanks
just learning.
 
First step -

When you drag from your listview (after setting the DragMode and DragIcon properties), do you see the mouse pointer change to the icon you chose?

Next Step -

When dropping onto your treeview control, does the DragDrop event fire? And if it does, does the Source parameter reference your listview control?

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top