private Control PickedUpControl; private Panel TargetArea; this.TargetArea.AllowDrop = true; private void DragControl_MouseDown(object sender, System.MouseEventArgs e) { this.PickedUpControl = (Control)sender; this.PickedUpControl.DoDragDrop(sender, DragDropEffects.Move); } private void TargetArea_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) { e.Effect = DragDropEffects.All; } private void TargetArea_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { this.TargetArea.Controls.Add(this.PickedUpControl); Point xy = this.TargetArea.PointToClient(new Point(e.X, e.Y)); this.PickedUpControl.Location = xy; } // The DragOver event is often redundant, but can be used to show the object moving private void TargetArea_DragOver(object sender, System.Windows.Forms.DragEventArgs e) { e.Effect = DragDropEffects.All; Point xy = this.PointToClient(new Point(e.X+1, e.Y+1)); this.PickedUpControl.Location = xy; }Another useful method if you need to actually *get* the object at that point in the DragDrop method is the .GetChildAtPoint() method (this would be *where* the Dragged-in control is being dropped, like say you were dropping the actual Text from one TextBox to another):
private void TargetArea_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { Point pt = this.TargetArea.PointToClient(new Point(e.X, e.Y)); Control ToControl = this.TargetArea.GetChildAtPoint(pt); ToControl.Text = this.PickedUpControl.Text; }~~Bonnie