private void control_DragEnter(object sender, DragEventArgs e){ e.Effect = DragDropEffects.None; }
DragOver Event
public class TestControlDesigner : ParentControlDesigner { public override void Initialize(System.ComponentModel.IComponent component) { base.Initialize(component); if (this.Control is TestControl) { this.EnableDesignMode(((TestControl)this.Control).WorkingArea, "WorkingArea"); } } protected override void OnDragOver(DragEventArgs de) { TestControl ctrl = ((TestControl)this.Control); // Screen coordinates to client Point point = ctrl.PointToClient(new Point(de.X, de.Y)); // What control is 'under the mouse cursor' Control child= ctrl.GetChildAtPoint(point); // 'Visual' Debug at design time ;) ctrl.Caption = $"{child?.Name} x={point.X} y={point.Y}"; // Only allow to drop on working area if (child == ctrl.WorkingArea) { de.Effect = DragDropEffects.Copy; } else { de.Effect = DragDropEffects.None; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)