473,388 Members | 1,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Listview drag and drop images to picturebox

Hi,

Does anyone have some example code they
can direct me too for drag dropping images
from a listview to PictureBox???

I have googled but not found anything I can get to work.
Jan 24 '12 #1
2 6080
Fr33dan
57
The only way I know of to do drag and drop from within your application is to manage it yourself using the MouseDown and MouseUp events.

In the MouseDown event on the ListView store the image that is being dragged. Then you check to see if there is an image being dragged in the MouseUp event and handle it. You'll have to implement the MouseUp event on all controls to clear out the current image being dragged if the user drags the image to somewhere other than the PictureBox.
Jan 24 '12 #2
lgm001
9
C#, piece of cake...

I assume that the images in the listview are in an ImageList?
In your mouse down event....
listView1.DoDragDrop(listView1.SelectedItems, DragDropEffects.Move);

In the picturebox's DragEnter event...

int len=e.Data.GetFormats().Length-1 ;
int i;
for (i = 0 ; i<=len ;i++)
{
if (e.Data.GetFormats()[i].Equals("System.Windows.Forms.ListView+SelectedLis tViewItemCollection"))
{
//The data from the drag source is moved to the target.
e.Effect = DragDropEffects.Move;
}
}

In your picturebox's DragDrop event

//Return if the items are not selected in the ListView control.
if(listView1.SelectedItems.Count==0)
{
return;
}
ListViewItem dragitem=listView1.SelectedItems[0];
PictureBox1.Image=ImageList1.Images[dragitem.ImageIndex].Image;
listView1.Items.Remove(dragItem);
}

This is pretty close... Some syntax errors may exist as I am doing this without the help of VS2010 at the moment.
Jan 25 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Curtis Justus | last post by:
Hi, My goal is to have a series of thumbnail images on a control/panel and to drag/drop those items onto another control (i.e. a treeview). I am able to drag one item and need to somehow select...
0
by: Andy | last post by:
Hi all, I'm developing an application which allows a drag and drop of files onto a ListView control. Everything works fine on my Windows XP development computer, but when i move the...
0
by: pamelafluente | last post by:
Hi, I have a PictureBox on a form. I wish to drag the image exposed by the PictureBox through the property "image" to a window of Windows Explorer. The new file will have a name assigned by the...
1
by: Alan T | last post by:
I have a tree view on the left and a list view on the right. I will drag and drop from list view to treeview, and also drag drop tree node on the same tree view. How do I differentiate I drag...
2
by: ngajjar | last post by:
An application I am working with has two listview controls. Items are added runtime from the database when form load. It requires a mechanism which allow user to drag item from a listview and drop in...
0
by: arvinds | last post by:
I have an application in which I have 2 forms. 1.Review Form 2. FilmForm. Review Form is used for Loading some images and we can transfer the Images from Review From to FilmForm by Drag-Drop...
2
by: Rotsey | last post by:
Hi, Does anyone have some example code they can direct me too for drag dropping images from a listview to PictureBox??? I have googled but not found anything I can get to work. rotsey
0
by: Rob Stevens | last post by:
Can someone show me how this is done? Just dragging and dropping an image into the richtextbox does nothing but print out the text about the image name. Thanks
1
by: Red Head | last post by:
Hello :) I would like to have an horizontal image list where you can drag and drop the images to reorder them (like slide reorder in powerpoint, but then in an horizontal way) so i had a look...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.