Results 1 to 6 of 6

Thread: DragDrop Dynamic Labels (on a Picbox)

Threaded View

  1. #1

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    DragDrop Dynamic Labels (on a Picbox)

    I cant seem to get this working...
    I have a picture box (with a map image)

    Right click it - pick add plane from the context menu lets you type a name into an input box and poof! a new label appears with that name on it.

    I would like to now be able to drag/drop the label to other places in the picture box
    (in case it matters, i also need to be able to click it - to view detail - and right click it to pick from another menu BUT, i could use right btn to move if needed)

    I mousedown.. and i get the no drag symbol... and nothing happens

    adds label
    Code:
    Private Sub AddPlane(Serial As String)
            Dim LBL As New Label
            LBL.Text = Trim(Serial)
            LBL.BackColor = Color.WhiteSmoke
            LBL.BorderStyle = BorderStyle.FixedSingle
            LBL.Top = MP.Y
            LBL.Left = MP.X
            LBL.Font = New Font(New FontFamily("Microsoft Sans Serif"), 11, FontStyle.Bold, GraphicsUnit.Point)
            LBL.ForeColor = Color.Crimson
            LBL.AutoSize = True
            LBL.Visible = True
            LBL.ContextMenuStrip = cms_plane
            LBL.AllowDrop = True
            pb_Map.Controls.Add(LBL)
    
            AddHandler LBL.Click, AddressOf PLANE_CLICK
            AddHandler LBL.MouseDown, AddressOf PLANE_MOUSEDOWN
            AddHandler LBL.DragEnter, AddressOf PLANE_DRAGENTER
            AddHandler LBL.DragDrop, AddressOf PLANE_DRAGDROP
        End Sub
    dragdrop code i have found "out there"
    Code:
    Private Sub PLANE_MOUSEDOWN(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
            If Button.MouseButtons <> Windows.Forms.MouseButtons.Left Then Exit Sub
            Dim LBL As Label = DirectCast(sender, Label)
            LBL.DoDragDrop(LBL.Text, DragDropEffects.Copy Or DragDropEffects.Move)
        End Sub
    
        Private Sub PLANE_DRAGENTER(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs)
            If e.Data.GetDataPresent(DataFormats.Text) Then
                e.Effect = DragDropEffects.Copy
            Else
                e.Effect = DragDropEffects.None
            End If
        End Sub
    
        Private Sub PLANE_DRAGDROP(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs)
            Dim LBL As Label = DirectCast(sender, Label)
            LBL.Text = e.Data.GetData(DataFormats.Text).ToString
        End Sub
    Last edited by Static; Aug 27th, 2013 at 10:15 PM.
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width