Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


C# Drag and Drop sample

Posted on 2006-04-23
Medium Priority
Last Modified: 2012-05-05
I need to implement drag and drop between two MDI child forms. If somebody wants to paste sample code, it can include two different MDI child forms of different classes. MDI parent contains one instance of each type. Let's say that dragging starts in one form and finishes in another.  When information is dropped, destination form can show coordinates where dragging was started.
This is simple and close to desired scenario for my program.
Question by:AlexFM
  • 2
LVL 11

Expert Comment

ID: 16520537
what do you want to drag and drop?
LVL 48

Author Comment

ID: 16522493
Source form contains image thumbnails. Destination page contains cells which can accept image or images. User can select one or more thumbnails on the source page, drag them to destination form and drop to free cell. Images are written to free cells starting from this free cell.
I don't have implementation details yet, because both these forms are not written. Therefore, I need to see a way to pass any information from one form to another, which may be, for example, source point coordinates, or anything else.
I want to know also how to set cursor when it is dragged over areas allowed and not allowed for dropping.
LVL 86

Accepted Solution

Mike Tomlinson earned 2000 total points
ID: 16526941
Hey AlexFM...

See here for the "big picture":

Basically you set the AllowDrop() property for whatever you want to receive things.  Then in the DragEnter() event, you test the data being sent to see if it is a format you want to receive.  If so, you set the e.Effect parameter accordingly.  I created my own DataObject class to handle this situation so I know exactly what is being dropped and I can use that to base my decision upon.  You can add whatever you want to that class so you could hold multiple things in it.  Finally in the DragDrop() event you pull the data object out and do something with it...
LVL 48

Author Comment

ID: 16527503
Great, this is good start point.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question