473,395 Members | 1,460 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,395 software developers and data experts.

Drag and Drop, help please

HaLo2FrEeEk
404 256MB
I've got a program that requires that the user pick a file or folder on their computer. Currently the user clicks Open Single in the File menu and an openFileDialog comes up; to open a folder the user clicks Batch from the File menu and an folderBrowserDialog comes up. I'd like to expand this to allow the user to simply drag a file or folder onto the program window, and I'm realizing how complicated drag n drop can be.

I'm starting by just testing folders. I've set up an event handler for the dragEnter and dragLeave events. When I drag a folder over the form the dragOver event handler confirms that the data being dragged is actually a folder and returns either true or false. The dragLeave handler then displays all the files in that folder when I let go of the mouse. The problem here is that while letting go of the mouse completes the drag and drop, so does dragging my mouse outside the form's bounds. I need a way to confirm that the data was actually dropped onto the form.

I've tried the DragDrop event, but it doesn't seem to do anything. I tried this simple code:

Expand|Select|Wrap|Line Numbers
  1. private void Form1_DragDrop(object sender, DragEventArgs e)
  2. {
  3.     MessageBox.Show("Data was dropped");
  4. }
then I tried dropping something onto the form. Nothing happened. I didn't get a messagebox, nothing.

So how can I get the program to only process the information if the data was actually dropped onto the form, and not if it was dragged onto then out of the form?
May 17 '10 #1
3 1367
Christian Binder
218 Expert 100+
@HaLo2FrEeEk
Did you set the Form's Property AllowDrop?
May 17 '10 #2
Curtis Rutland
3,256 Expert 2GB
@HaLo2FrEeEk
I actually wrote an article here on this site about this:

http://bytes.com/topic/net/insights/...-c-net-program
May 17 '10 #3
HaLo2FrEeEk
404 256MB
Ergh, I actually ended up figuring it out, I would like to take a look at that link though, thanks!
May 17 '10 #4

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

Similar topics

2
by: SamSpade | last post by:
There seems to be two ways to put things on the clipboard ( I don't mean different formats): SetClipboardData and OleSetClipboard If I want to get data off the clipboard do I care how it was put...
4
by: zav | last post by:
Hi all i`m having a small problem with windows forms, i`m attempting to provide the following functionality to a form. Ability to drag and drop another form onto a form and then to dock this...
4
by: Qingdong Z. | last post by:
I have a VS.NET windows application which use drag-drop feather. It works fine when application start, but stops working after application run one or two days. The application is related to Video...
1
by: Kevin L | last post by:
I have a Panel control that I currently allow the user to drag and reposition on a form at runtime. This Panel control contains a Label control. I would like to allow the user to drag the PANEL...
0
by: Pesso | last post by:
I'm loading a text file to a RichTextBox control to drag a selection of a text and drop it into a tree view control. It works except after the drag and drop operation the RichTextBox scrolls to the...
1
by: timnels | last post by:
I have created a muti-select treeview control. Problem is I am now trying to implement drag/drop in the application that uses it. It seems the mouse down and mouse move events fire before the...
1
by: gilan | last post by:
I'm building a javascript WYSIWYG editor using designMode. My main problem right now is that I'm trying to create dragging functions for certain classes of divs, but Firefox's own designMode...
4
by: Jeff | last post by:
Hello, I am trying to drag and drop a label control from one cell in a tablelayoutpanel to another (VB2005). There is no problem if both cells are visible, but i cannot get the tablelayoutpanel...
2
by: bob | last post by:
Hi all, I have a treeview that has drag drop. Works well enough but... If you drag out of bounds of the treeview the nodrop icon comes on. Fair enough. But when I move back inside the treeview...
0
by: babai28 | last post by:
Hi, I have a situation where in a winform application I have a tree view from which I need to drag drop tree nodes into a textBox contained in another application window. I used the following code...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.