Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Drag & Drop - Part 2
Message
De
11/07/2009 12:48:15
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01411209
Message ID:
01411611
Vues:
32
Kevin,

Yeah, as Viv says, you'd have to add a copy method to your PickedUpControl to make a copy, or have a utility method that does a copy of any object, or even this might be a good use of an extension method ... I haven't even played with that at all, so I don't have any suggestions off the top of my head for how to do that.

As far as the cursor goes, I haven't experimented with this, but try changing it in the TargetArea_DragDrop handler instead of the PickedUpControl_DragLeave handler.

~~Bonnie



>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?
>
>Thanks
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform