Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Drop 'n drag (and stay)
Message
De
14/01/2005 18:30:53
Victor Verheij
International Film Festival Rotterdam
Rotterdam, Pays-Bas
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Drop 'n drag (and stay)
Versions des environnements
Environment:
VB.NET 1.1
OS:
Windows XP SP2
Divers
Thread ID:
00977399
Message ID:
00977399
Vues:
59
Hi, haven't been here for a while....

Buisy learning .net

Wel, probably this is not the right place for my question but, here ik comes.

I'm trying to drop a button on a panel at the location where i release the mouse.

I've got the drag and drop part down, but can't figure out how to let is stay on the location in the panel where i release my mouse.

Below is the code i have.
Public Class Form1
    Inherits System.Windows.Forms.Form
    Private m_PickedUp As Button

    Private Sub btnDrag_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnDrag.MouseDown
        m_PickedUp = CType(sender, Button)
        m_PickedUp.DoDragDrop(sender, DragDropEffects.Copy)
    End Sub

    Private Sub pnlDrop_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles pnlDrop.DragEnter
        e.Effect = DragDropEffects.Copy
    End Sub

    Private Sub pnlDrop_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles pnlDrop.DragDrop
        Dim theBtn As Button = CType(m_PickedUp, Button)
        pnlDrop.Controls.Add(theBtn)
        'theBtn.Top = e.X
        'theBtn.Left = e.Y
        Dim xy As New System.Drawing.Point(e.X, e.Y)
        theBtn.Location = xy
        theBtn.Text = e.X.ToString & " : " & e.Y.ToString 'to get an idea of what is happening.    
    End Sub
End Class
Any help is very much appreciated
thanks, Victor
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform