I've inherited a body of C# code that has a 'Designer Host' (DH) based UI.
Custom controls are selected from a 'toolbox' window and placed/sized
in the DH interface. I'm trying to add a feature that allows the user to
drag data, specifically a string, from another window to one of these
controls,
without success. Part of the control definition is:
[Designer(typeof(TactControlDesigner))]
public class TactControl : UserControl
{
...
protected void tactDragOver(object sender,
System.Windows.Forms.DragEventArgs e) {
Console.WriteLine("drag over tact");
e.Effect = DragDropEffects.Link;
}
protected void tactDragDrop(object sender,
System.Windows.Forms.DragEventArgs e) {
string dropArg = (string) e.Data.GetData(typeof (System.String));
if (dropArg != null) {
MessageBox.Show(dropArg);
}
}
public TactControl()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitializeComponent call
this.AllowDrop = true;
this.DragOver += new System.Windows.Forms.DragEventHandler(tactDragOver );
this.DragDrop += new System.Windows.Forms.DragEventHandler(tactDragDrop );
}
. . . neither of the drag event handlers ever get called.
I had thought that this DH technology (about which I'm extremely ignorant)
might not be creating windows for these controls, but Spy++ shows otherwise.
The definition of the DH class being used starts off:
[ProvideProperty("Name", typeof(IComponent))]
internal class DesignerHost : IDesignerHost, IContainer,
IComponentChangeService, IExtenderProvider, ITypeDescriptorFilterService,
IExtenderListService, IExtenderProviderService
{
I'm guessing that the DH stuff might mess with the drag-drop procedure
in order to implement its own toolbox interactions, but I've no idea how,
and no idea where to look.
Any thoughts or pointers would be appreciated . . .