private System.Windows.Control PickedUpControl; // You could use this same event handler for anything you want to move, not just this button private void Button_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { this.PickedUpControl = (Control)sender; this.PickedUpControl.DoDragDrop(sender, DragDropEffects.Move); }Let's also assume the Panel is called TargetArea, and you'd have the following code in the DragOver and DragDrop handlers:
private void TargetArea_DragOver(object sender, System.Windows.Forms.DragEventArgs e) { e.Effect = DragDropEffects.Move; Point xy = this.PointToClient(new Point(e.X+1, e.Y+1)); this.PickedUpControl.Location = xy; } private void TargetArea_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { Point xy = this.TargetArea.PointToClient(new Point(e.X, e.Y)); this.TargetArea.Controls.Add(this.PickedUpControl); this.PickedUpControl.Location = xy; }The only thing this doesn't do is show the button once the the mouse has entered the target area ... you still see the little drag-effect box, but the button itself doesn't show up until you drop it. I never played around with it enough to figure out how to show it moving around inside the TargetArea, but it may be do-able. In any case, this code *does* move the button into the Panel (assuming I didn't leave out any important bits from my sample app).