Lesson Summary

■ The drag-and-drop operation is initiated by calling the DoDragDrop method on the source control. This is usually done in the MouseDown event handler for the source control. The DoDragDrop method takes two parameters: an Object parameter that contains the data to be dragged and dropped and a DragDropEffects enumeration parameter that represents the effect or effects that are allowed for this operation.

■ The DragEnter event on the target control is used to set the allowed effects for the target control. You can examine the data in the e.Data object that is present in the event parameters and determine if the data is appropriate for the control. If the data is not appropriate for the control, you can cancel the DragDrop operation by setting the e.Effect property to None.

■ The drag-and-drop operation is completed in the DragDrop event on the target control. You must write code to complete the appropriate operation in this event.

■ Data can be dragged and dropped between controls in different applications. No additional steps need to be taken to enable drag-and-drop operations that take place between applications.

■ Drag-and-drop operations in TreeView controls are begun by calling the DoDragDrop method in the TreeView.ItemDrag event handler. The rest of the drag-and-drop process is generally the same as drag-and-drop operations between other controls.

0 0

Post a comment