Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Drag & Drop - Part 2
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01411209
Message ID:
01411349
Views:
26
>I finally was able, using Bonnie's code, to get my drag & drop working. I still have some problems though.
>
>I placed 2 panels on a form. The panel to be dragged is called PickedUpControl and the target is called TargetArea:
>
>
>public partial class Form1 : Form
>{
>    Cursor DefaultCursor;
>
>    public Form1()
>    {
>        InitializeComponent();
>        DefaultCursor = this.Cursor;
>    }
>
>    private void PickedUpControl_MouseDown(object sender, MouseEventArgs e)
>    {
>        Cursor oCursor = new Cursor(@"C:\Projects\Samples\DragDrop\hpoint.cur");
>        this.Cursor = oCursor;
>
>        this.PickedUpControl.DoDragDrop(sender, DragDropEffects.Copy);
>    }
>
>    private void TargetArea_DragEnter(object sender, DragEventArgs e)
>    {
>        e.Effect = DragDropEffects.Copy;
>    }
>
>    private void TargetArea_DragDrop(object sender, DragEventArgs e)
>    {
>        this.TargetArea.Controls.Add(this.PickedUpControl);
>
>        Point xy = this.TargetArea.PointToClient(new Point(e.X, e.Y));
>        this.PickedUpControl.Location = xy;
>    }
>
>    private void PickedUpControl_GiveFeedback(object sender, GiveFeedbackEventArgs e)
>    {
>        e.UseDefaultCursors = false;
>    }
>
>    private void PickedUpControl_DragLeave(object sender, EventArgs e)
>    {
>        this.Cursor = DefaultCursor;
>    }
>}
>
>
>1). I can't seem to get the cursor to reset to default after the drag/drop is done.
>2) The dragged pane is removed and placed in the target. How do I copy it instead?

If you want a copy you have to MAKE a copy - you can't site the same object in two locations.

From Help:
A Control can only be assigned to one Control..::.ControlCollection at a time. If the Control is already a child of another control it is removed from that control before it is added to another control.

Dunno about the cursor......
Previous
Reply
Map
View

Click here to load this message in the networking platform