O'Reilly logo

Windows Forms Programming in C# by Chris Sells

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Drag and Drop

No matter what kind of controls you're using or building, often you'd like to enable the user to drag data from one to another. This communication protocol, known as drag and drop, has long been standardized and is fully supported in WinForms for both targets and sources.

The Drop Target

Adding drag and drop to your application involves two elements: the drop target and the drop source. First, you must have a control that supports having things dragged and dropped onto it. This kind of control is known as the drop target. You designate your target by setting the AllowDrop property of the control to true.

Next, you make the target control subscribe to one or more of the drag-and-drop events:

  • DragEnter is fired when the mouse enters ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required