THE ZEPINT NETWORK

programmer assist

Desktop Development Desktop Development XML Feeds

Desktop Development Questions Desktop Development Solutions Desktop Development Articles

Desktop application development incorporates all technologies of developing applications for operating systems including Windows Vista, Windows XP, Mac OSX and Linux distributions.

C# - App - How to Drag and Drop from the desktop to a Panel in a Form?

DiggBlinkRedditDeliciousTechnorati

question by Alfonso2968 | Hard

Hello,

I am New here and fairly new to programming.

I have searched everything and all I can find is how to drag and drop within a form from panel to panel.

What I need to do is Drag an image from the desktop or from an open folder to a panel on my form.

This will be done for a few images and then on Buttonclik I need to save each image in its own folder.

Any help is much appreciated.

Here is what I have on the events - for d&d

This allows me to drag and drop within the form but trying to drag from desktop to panel1 doesn't work.
Code: ( text )

1.
private void panel_DragDrop(object sender, DragEventArgs e)
2.
{
3.
//target control will accept data here
4.
Panel destination = (Panel)sender;
5.
destination.BackgroundImage = (Bitmap)e.Data.GetData(typeof(Bitmap));
6.

7.
}
8.

9.

10.

11.

12.
private void panel_DragEnter(object sender, DragEventArgs e)
13.
{
14.
//As we are interested in Image data only we will check this as follows
15.
if (e.Data.GetDataPresent(typeof(Bitmap)))
16.
{
17.
e.Effect = DragDropEffects.Copy;
18.
}
19.
else
20.
{
21.
e.Effect = DragDropEffects.None;
22.
}
23.

24.
}
25.

26.

27.
private void panel_MouseDown(object sender, MouseEventArgs e)
28.
{
29.
//we will pass the data that user wants to drag DoDragDrop method is used for holding data
30.
//DoDragDrop accepts two paramete first paramter is data(image,file,text etc) and second paramter
31.
//specify either user wants to copy the data or move data
32.

33.
Panel source = (Panel)sender;
34.
DoDragDrop(source.BackgroundImage, DragDropEffects.Copy);
35.

36.

37.
}

Post reply Subscriptions

Got a Desktop Development Question?

Just Sign Up and ask the top Desktop Development experts!

Search via Google

User Login

Email Address

Password

Desktop Development Experts

Rank Expert Points
#1 martinig 500
This a list of the Top Desktop Development experts, how many points do you have?

Leading Experts

Rank Expert Points
#1 frankzzsword 4650
#2 Bejaan 2950
#3 csfreak 1100
#4 Anurag 700
#5 keyvez 700
#6 nnarasimha 600
#7 Nakata 600
#8 martinig 600
#9 mastercomputers 550
#10 Abhishek Chatterjee 250
#11 Abels 250
#12 Huntress 150
#13 Adkron 150
#14 Yogesh 100
#15 lexxwern 100
This is a list of overall best performing experts, how many points do you have?