Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Drop 'n drag (and stay)
Message
From
14/01/2005 18:30:53
Victor Verheij
International Film Festival Rotterdam
Rotterdam, Netherlands
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Drop 'n drag (and stay)
Environment versions
Environment:
VB.NET 1.1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
00977399
Message ID:
00977399
Views:
58
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
Next
Reply
Map
View

Click here to load this message in the networking platform