<!-- Article Starts - DO NOT ADD HTML/BODY START TAGS-->
Here's a problem that comes up pretty regularly: You have a complex user interface with a number of controls, groups of which need to be reused in different places. To manage the complexity and facilitate reuse, you encapsulate each group of controls in a UserControl. All works well, until you need to perform a drag-and-drop operation involving one of the child controls in one of your UserControls. The UserControl intercepts drag-and-drop events, so they never make it to the child controls.
This problem must come up all the time, but oddly enough, there isn't much written about it in the Microsoft newsgroups. This article addresses the problem and provides a simple solution along with a sample project.
The Simple Solution
The solution to this problem is simple, but it isn't intuitive. To pass drag-and-drop events to child controls in a UserControl, set the AllowDrop property of the UserControl to false in the UserControl project. Then set the AllowDrop properties of its child controls to true. Once these changes are made, the UserControl won't intercept drag-and-drop events intended for its child controls.
Note that changing the UserControl's AllowDrop property in a client form has no effect. When the UserControl is added to a form, its child controls will receive drag-and-drop events regardless of whether the UserControl's AllowDrop property is set to true or false.
The Demo Project
This article includes a simple demo solution that shows how to pass drag-and-drop events to child controls. The demo contains two projects, UserControl and TestHarness. The purposes of the projects are self-explanatory.
The TestHarness contains three controls; a button to drag, an 'ordinary' text box to drop it on, and another text box inside a UserControl. The ordinary text box is provided to verify that drag-and-drop is working; drag the button to this text box to verify. The UserControl passes a drop event to its child text box; drag the button to this text box to verify.
Please post any questions here; I'll check in periodically to answer them.